feat(opensearch): add amount and customer_id as filters and handle name for different indexes#7073
Merged
likhinbopanna merged 8 commits intomainfrom Feb 7, 2025
Merged
Conversation
Changed Files
|
su-shivanshmathur
requested changes
Jan 20, 2025
su-shivanshmathur
previously approved these changes
Feb 5, 2025
su-shivanshmathur
approved these changes
Feb 6, 2025
apoorvdixit88
approved these changes
Feb 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
amountfilteramountas a filter / category for global search.customer_idfiltercustomer_idas a filter.customer_idfilter on theCustomerspage, which uses global search.Additional Changes
Motivation and Context
For better search experience based on filters using global search and also on the Customers page.
How did you test it?
amountfilter:You can see the amount filter getting applied, and should get results after the amount filter is applied.
Sample opensearch query structure:
amountfield in the payload)Index: SessionizerPaymentIntents Payload: { "query": { "bool": { "filter": [ { "multi_match": { "type": "phrase", "query": "usd", "lenient": true } }, { "terms": { "amount": [ 600 ] } } ], "must": [ { "bool": { "must": [ { "bool": { "should": [ { "bool": { "must": [ { "term": { "organization_id.keyword": { "value": "org_jpjr9NADZXjHCMa592aw" } } } ] } } ], "minimum_should_match": 1 } } ] } } ] } }, "sort": [ { "@timestamp": { "order": "desc" } } ] }refund_amountbeing used here)Index: SessionizerRefunds Payload: { "query": { "bool": { "filter": [ { "multi_match": { "type": "phrase", "query": "usd", "lenient": true } }, { "terms": { "refund_amount": [ 600 ] } } ], "must": [ { "bool": { "must": [ { "bool": { "should": [ { "bool": { "must": [ { "term": { "organization_id.keyword": { "value": "org_jpjr9NADZXjHCMa592aw" } } } ] } } ], "minimum_should_match": 1 } } ] } } ] } }, "sort": [ { "@timestamp": { "order": "desc" } } ] }[ { "count": 0, "index": "payment_attempts", "hits": [], "status": "Success" }, { "count": 0, "index": "payment_intents", "hits": [], "status": "Success" }, { "count": 1, "index": "refunds", "hits": [ { "@timestamp": "2025-01-20T13:02:17Z", "attempt_id": "pay_ND5OdiSMSt6lhWovQup1_1", "connector": "stripe_test", "connector_refund_id": "dummy_ref_isNEfXmc0SW2r0cvaHvc", "connector_transaction_id": "pay_dWLQFQ9O5CcNP73haAqF", "created_at": 1737378137, "currency": "USD", "description": "Customer returned product", "external_reference_id": "ref_VIVDwLPl0zwwrRSJtnMP", "headers": {}, "internal_reference_id": "refid_EqKX3XCwLUAw9vd8bk9Z", "merchant_id": "merchant_1735041293", "modified_at": 1737378138, "organization_id": "org_jpjr9NADZXjHCMa592aw", "payment_id": "pay_ND5OdiSMSt6lhWovQup1", "profile_id": "pro_PDu2uP7icn3iWcB7WEUI", "refund_amount": 600, "refund_arn": "", "refund_error_code": null, "refund_error_message": null, "refund_id": "ref_VIVDwLPl0zwwrRSJtnMP", "refund_reason": "Customer returned product", "refund_status": "success", "refund_type": "instant_refund", "sent_to_gateway": true, "source_type": "kafka", "tenant_id": "public", "timestamp": "2025-01-20T13:02:17Z", "total_amount": 10000 } ], "status": "Success" }, { "count": 0, "index": "disputes", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_payment_attempts", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_payment_intents", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_refunds", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_disputes", "hits": [], "status": "Failure" } ]customer_idfilter:[ { "count": 0, "index": "payment_attempts", "hits": [], "status": "Success" }, { "count": 6, "index": "payment_intents", "hits": [ { "@timestamp": "2025-01-20T13:01:37Z", "active_attempt_id": "pay_ND5OdiSMSt6lhWovQup1_1", "amount": 10000, "amount_captured": 10000, "attempt_count": 1, "billing_details": null, "business_country": null, "business_label": "default", "client_secret": "pay_ND5OdiSMSt6lhWovQup1_secret_TWKqD8yqhgbyEXowOSe3", "connector_id": null, "created_at": 1737378097, "currency": "USD", "customer_email": "f6cd0753a831880835a0e0d23136ef66318d8303605bd37fa80b4ecf248bd303", "customer_id": "StripeCustomer", "description": "Its my first payment request", "feature_metadata": { "apple_pay_recurring_details": null, "redirect_response": null, "search_tags": [ "1259195bb05bb44ea78ab60b26a54065183f91b3c5b3c2c074cadcf521305a79", "9bff7b14d0a57a00d98f5eb742418a50b3bdfe5993f16b4219bfa31989bdf80f" ] }, "headers": {}, "merchant_id": "merchant_1735041293", "merchant_order_reference_id": null, "metadata": "{\"data2\":\"camel\",\"login_date\":\"2019-09-10T10:11:12Z\",\"new_customer\":\"true\"}", "modified_at": 1737378099, "off_session": null, "organization_id": "org_jpjr9NADZXjHCMa592aw", "payment_confirm_source": null, "payment_id": "pay_ND5OdiSMSt6lhWovQup1", "profile_id": "pro_PDu2uP7icn3iWcB7WEUI", "return_url": "https://google.com/", "setup_future_usage": null, "shipping_details": null, "source_type": "kafka", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "status": "succeeded", "tenant_id": "public", "timestamp": "2025-01-20T13:01:37Z" }, { "@timestamp": "2025-01-20T09:56:07Z", "active_attempt_id": "pay_bWGMDT130V4mrDskx9Lt_1", "amount": 6540, "amount_captured": 6540, "attempt_count": 1, "billing_details": null, "business_country": null, "business_label": "default", "client_secret": "pay_bWGMDT130V4mrDskx9Lt_secret_VnTfCd82o07H59gQOmdA", "connector_id": null, "created_at": 1737366967, "currency": "USD", "customer_email": "6ede5d9641558aef42ea1cff12554f6d6f56081319465af002f0842aec34c763", "customer_id": "StripeCustomer", "description": "Its my first payment request", "feature_metadata": null, "headers": {}, "merchant_id": "merchant_1735041293", "merchant_order_reference_id": null, "metadata": "{\"udf1\":\"value1\",\"login_date\":\"2019-09-10T10:11:12Z\",\"new_customer\":\"true\"}", "modified_at": 1737366971, "off_session": null, "organization_id": "org_jpjr9NADZXjHCMa592aw", "payment_confirm_source": null, "payment_id": "pay_bWGMDT130V4mrDskx9Lt", "profile_id": "pro_PDu2uP7icn3iWcB7WEUI", "return_url": "https://google.com/", "setup_future_usage": null, "shipping_details": null, "source_type": "kafka", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "status": "succeeded", "tenant_id": "public", "timestamp": "2025-01-20T09:56:07Z" }, { "@timestamp": "2025-01-20T09:50:20Z", "active_attempt_id": "pay_OEYLy5ZKarSVBVOyhsON_1", "amount": 6540, "amount_captured": 6540, "attempt_count": 1, "billing_details": null, "business_country": null, "business_label": "default", "client_secret": "pay_OEYLy5ZKarSVBVOyhsON_secret_EmNPjhoI9FK8aVO30Ss4", "connector_id": null, "created_at": 1737366620, "currency": "USD", "customer_email": "6ede5d9641558aef42ea1cff12554f6d6f56081319465af002f0842aec34c763", "customer_id": "StripeCustomer", "description": "Its my first payment request", "feature_metadata": null, "headers": {}, "merchant_id": "merchant_1735041293", "merchant_order_reference_id": null, "metadata": "{\"udf1\":\"value1\",\"login_date\":\"2019-09-10T10:11:12Z\",\"new_customer\":\"true\"}", "modified_at": 1737366627, "off_session": null, "organization_id": "org_jpjr9NADZXjHCMa592aw", "payment_confirm_source": null, "payment_id": "pay_OEYLy5ZKarSVBVOyhsON", "profile_id": "pro_PDu2uP7icn3iWcB7WEUI", "return_url": "https://google.com/", "setup_future_usage": null, "shipping_details": null, "source_type": "kafka", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "status": "succeeded", "tenant_id": "public", "timestamp": "2025-01-20T09:50:20Z" }, { "@timestamp": "2025-01-20T09:41:41Z", "active_attempt_id": "pay_lJJCj6jGDPPOtwb3YucZ_1", "amount": 10000, "amount_captured": 10000, "attempt_count": 1, "billing_details": null, "business_country": null, "business_label": "default", "client_secret": "pay_lJJCj6jGDPPOtwb3YucZ_secret_xDqPGN0uREz1mSDLeQv9", "connector_id": null, "created_at": 1737366101, "currency": "USD", "customer_email": "f6cd0753a831880835a0e0d23136ef66318d8303605bd37fa80b4ecf248bd303", "customer_id": "StripeCustomer", "description": "Its my first payment request", "feature_metadata": { "apple_pay_recurring_details": null, "redirect_response": null, "search_tags": [ "1259195bb05bb44ea78ab60b26a54065183f91b3c5b3c2c074cadcf521305a79", "9bff7b14d0a57a00d98f5eb742418a50b3bdfe5993f16b4219bfa31989bdf80f" ] }, "headers": {}, "merchant_id": "merchant_1735041293", "merchant_order_reference_id": null, "metadata": "{\"data2\":\"camel\",\"login_date\":\"2019-09-10T10:11:12Z\",\"new_customer\":\"true\"}", "modified_at": 1737366102, "off_session": null, "organization_id": "org_jpjr9NADZXjHCMa592aw", "payment_confirm_source": null, "payment_id": "pay_lJJCj6jGDPPOtwb3YucZ", "profile_id": "pro_PDu2uP7icn3iWcB7WEUI", "return_url": "https://google.com/", "setup_future_usage": null, "shipping_details": null, "source_type": "kafka", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "status": "succeeded", "tenant_id": "public", "timestamp": "2025-01-20T09:41:41Z" }, { "@timestamp": "2025-01-20T08:13:08Z", "active_attempt_id": "pay_A3dPrR94eHFTlvT7CSXT_1", "amount": 10000, "amount_captured": 10000, "attempt_count": 1, "billing_details": null, "business_country": null, "business_label": "default", "client_secret": "pay_A3dPrR94eHFTlvT7CSXT_secret_3FUMXfThPXlRp0kZyvPc", "connector_id": null, "created_at": 1737360788, "currency": "USD", "customer_email": "f6cd0753a831880835a0e0d23136ef66318d8303605bd37fa80b4ecf248bd303", "customer_id": "StripeCustomer", "description": "Its my first payment request", "feature_metadata": { "apple_pay_recurring_details": null, "redirect_response": null, "search_tags": [ "1259195bb05bb44ea78ab60b26a54065183f91b3c5b3c2c074cadcf521305a79", "9bff7b14d0a57a00d98f5eb742418a50b3bdfe5993f16b4219bfa31989bdf80f" ] }, "headers": {}, "merchant_id": "merchant_1735041293", "merchant_order_reference_id": null, "metadata": "{\"data2\":\"camel\",\"login_date\":\"2019-09-10T10:11:12Z\",\"new_customer\":\"true\"}", "modified_at": 1737360790, "off_session": null, "organization_id": "org_jpjr9NADZXjHCMa592aw", "payment_confirm_source": null, "payment_id": "pay_A3dPrR94eHFTlvT7CSXT", "profile_id": "pro_PDu2uP7icn3iWcB7WEUI", "return_url": "https://google.com/", "setup_future_usage": null, "shipping_details": null, "source_type": "kafka", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "status": "succeeded", "tenant_id": "public", "timestamp": "2025-01-20T08:13:08Z" }, { "@timestamp": "2024-12-24T11:56:12Z", "active_attempt_id": "pay_5cvsiaRXZRzRg6VNvJ5e_1", "amount": 10000, "amount_captured": 10000, "attempt_count": 1, "billing_details": null, "business_country": null, "business_label": "default", "client_secret": "pay_5cvsiaRXZRzRg6VNvJ5e_secret_XRpkHJHWahWqIaYKiovr", "connector_id": null, "created_at": 1735041372, "currency": "USD", "customer_email": "f6cd0753a831880835a0e0d23136ef66318d8303605bd37fa80b4ecf248bd303", "customer_id": "StripeCustomer", "description": "Its my first payment request", "feature_metadata": { "redirect_response": null, "search_tags": [ "1259195bb05bb44ea78ab60b26a54065183f91b3c5b3c2c074cadcf521305a79", "9bff7b14d0a57a00d98f5eb742418a50b3bdfe5993f16b4219bfa31989bdf80f" ] }, "headers": {}, "merchant_id": "merchant_1735041293", "merchant_order_reference_id": null, "metadata": "{\"data2\":\"camel\",\"login_date\":\"2019-09-10T10:11:12Z\",\"new_customer\":\"true\"}", "modified_at": 1735041373, "off_session": null, "organization_id": "org_jpjr9NADZXjHCMa592aw", "payment_confirm_source": null, "payment_id": "pay_5cvsiaRXZRzRg6VNvJ5e", "profile_id": "pro_PDu2uP7icn3iWcB7WEUI", "return_url": "https://google.com/", "setup_future_usage": null, "shipping_details": null, "source_type": "kafka", "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "status": "succeeded", "tenant_id": "public", "timestamp": "2024-12-24T11:56:12Z" } ], "status": "Success" }, { "count": 0, "index": "refunds", "hits": [], "status": "Success" }, { "count": 0, "index": "disputes", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_payment_attempts", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_payment_intents", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_refunds", "hits": [], "status": "Failure" }, { "count": 0, "index": "sessionizer_disputes", "hits": [], "status": "Failure" } ]customer_idfilter getting applied when building the opensearch query:Index: PaymentIntents Payload: { "query": { "bool": { "filter": [ { "multi_match": { "type": "phrase", "query": "usd", "lenient": true } }, { "terms": { "customer_id.keyword": [ "StripeCustomer" ] } } ], "must": [ { "bool": { "must": [ { "bool": { "should": [ { "bool": { "must": [ { "term": { "organization_id.keyword": { "value": "org_jpjr9NADZXjHCMa592aw" } } } ] } } ], "minimum_should_match": 1 } } ] } } ] } }, "sort": [ { "@timestamp": { "order": "desc" } } ] }Checklist
cargo +nightly fmt --allcargo clippy