Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(globalsearch): Implement tag-based filters in global search #5151

Merged
merged 3 commits into from
Jul 1, 2024

Conversation

tsdk02
Copy link
Contributor

@tsdk02 tsdk02 commented Jun 27, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Added more explicit filters to global search:
Currently we rely on free form text search where opensearch matches the keywords across the entire document

Filters added currently:

  • payment method
  • currency
  • status
  • customer_email

Can map multiple options for every filter for global search

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Adding a more refined & strict search query where we do exact matches on fields provides better results

How did you test it?

Tested using local data by sending cURL requests through Postman.

curl --location 'http://localhost:8080/analytics/v1/search' \
--header 'Accept: */*' \
--header 'Accept-Language: en-US,en;q=0.9' \
--header 'Connection: keep-alive' \
--header 'Content-Type: application/json' \
--header 'Origin: http://localhost:9000' \
--header 'Referer: http://localhost:9000/' \
--header 'Sec-Fetch-Dest: empty' \
--header 'Sec-Fetch-Mode: cors' \
--header 'Sec-Fetch-Site: same-site' \
--header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \
--header 'api-key: hyperswitch' \
--header 'authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiZjQ1YWViMDgtOTBmNS00ZTM5LTljMjMtNDRkZmYxM2E4ODgwIiwibWVyY2hhbnRfaWQiOiJtZXJjaGFudF8xNzE4MDE4MjIyIiwicm9sZV9pZCI6Im9yZ19hZG1pbiIsImV4cCI6MTcxOTk5MTA0MSwib3JnX2lkIjoib3JnXzFuR09tR2N2dUxPVnBXUDJYMUFIIn0.VWP2Lj3US2qPb0nIZtpR2cHyfDpYBsR9lc9PvfQNdXY' \
--header 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--data '{
    "query": "merchant_1718018222",
    "filters": {
        "currency": [
            "INR", "USD"
        ]
    }
}'
Screenshot 2024-06-28 at 1 48 53 AM Screenshot 2024-06-28 at 1 51 11 AM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@tsdk02 tsdk02 self-assigned this Jun 27, 2024
@tsdk02 tsdk02 requested a review from a team as a code owner June 27, 2024 20:28
@tsdk02 tsdk02 linked an issue Jun 27, 2024 that may be closed by this pull request
@tsdk02 tsdk02 requested review from lsampras and ivor11 June 27, 2024 20:29
Copy link
Member

@lsampras lsampras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest looks good

.add_filter_clause("payment_method.keyword".to_string(), payment_method)
.switch()?;
};
if let Some(customer_email) = filters.customer_email {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if let Some(customer_email) = filters.customer_email {
if let Some(customer_email) = filters.customer_email && !customer_email.is_empty() {

can we add this sort of validation to make sure that empty arrays are ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, added the validations to ignore empty arrays

@tsdk02 tsdk02 requested a review from Abhitator216 July 1, 2024 09:13
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 1, 2024
Merged via the queue into main with commit 4314fcd Jul 1, 2024
11 checks passed
@Gnanasundari24 Gnanasundari24 deleted the global-search-tag-based-filters branch July 1, 2024 12:31
pixincreate added a commit that referenced this pull request Jul 2, 2024
…ror-handling-in-cypress

* 'main' of github.com:juspay/hyperswitch:
  fix(auth_methods): Add checks for duplicate `auth_method` in create API (#5161)
  chore(version): 2024.07.02.0
  fix(router): rename the browser name header to `x-browser-name` (#5162)
  fix(router): mark retry payment as failure if `connector_tokenization` fails (#5114)
  fix(connector): [Paypal] dispute webhook deserialization failure (#5111)
  feat(analytics): Add v2 payment analytics (payment-intents analytics) (#5150)
  feat(globalsearch): Implement tag-based filters in global search (#5151)
  refactor(connector): Add amount conversion framework to iatapay along with amount conversion code to connector template (#4866)
  feat(payment_link): add multiple custom css support in business level  (#5137)
  feat(connector): [Bambora Apac] Template for integration (#5062)
  feat(tls): add support for https in actix web (#5089)
  chore(ci): fix ci tests failing by removing them (#5167)
  chore(version): 2024.07.01.0
  chore(postman): update Postman collection files
  ci(postman): log request id for user tests (#5159)
  chore(euclid_wasm): make field domain optional wasm (#5154)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(globalsearch): Implement tag-based filters in global search
5 participants