-
Notifications
You must be signed in to change notification settings - Fork 63
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
fix: Fuzzy & operator usage when handling Intelligent Search API requests #2204
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 54da0df:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good! I'll test it in practice before approval, but I left some comments so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
But I'll wait for the reply here, it makes sense to me but idk if in fact it does 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Co-authored-by: Eduardo Formiga <[email protected]>
Co-authored-by: Lucas Feijó <[email protected]>
Co-authored-by: Lucas Feijó <[email protected]>
627df6c
to
bea9e5b
Compare
5a8d51f
to
bea9e5b
Compare
## What's the purpose of this pull request? Fix bugs related to the addition of fuzzy parameters to the URL on PLP (category page and search page). See jira tasks on the references section below. ## How it works? By using the `replace` function instead of `push` we are able to update the URL adding the fuzzy parameters to it without triggering the navigation. Thus, it doesn't re-render the page and it doesn't affect the back button to previous page. It happens because the `replace` doesn't add the new URL as a new entry on the `history` stack. ## How to test it? Test a category page (example: `/office`) and test search also. Both pages should have its URL updated to add the fuzzy and operator params, but shouldn't re-render. Also, if you click the browser return button you should go to the previous page (Home, for example, if you were on the Home page and then went to the category page) normally. ### Starters Deploy Preview <!--- Add a link to a deploy preview from `gatsby.store` AND `nextjs.store` with this branch being used. ---> <!--- Tip: You can get an installable version of this branch from the CodeSandbox generated when this PR is created. ---> ## References - #2204 - [[Jira task] Fuzzy bug: return to previous page](https://vtex-dev.atlassian.net/jira/software/c/projects/SFS/boards/1051?selectedIssue=SFS-802) - [[Jira task] Fuzzy bug: re-render](https://vtex-dev.atlassian.net/browse/SFS-515) - [History: `replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState) - [Next router: `replace` function](https://nextjs.org/docs/pages/api-reference/functions/use-router#routerreplace)
## What's the purpose of this pull request? This PR reverts the following PRs: - #2307 - #2204 Also, it resolves the conflicts from the current main branch. ## How it works? We are removing the reload issue caused by the use of fuzzy logic and operators in handling IS requests. The team will try another approach to address the usage of fuzzy logic and operators in IS requests allowing the search engine decide the best parameters for the search. ## How to test it? You can run the project locally and double-check if the PLP/Search page just loads once. Also, you can use the preview URL from starter PR: PLP: https://sfj-728d5af--starter.preview.vtex.app/office Search: https://sfj-728d5af--starter.preview.vtex.app/s?q=shirt&sort=score_desc&page=0 ### Starters Deploy Preview - vtex-sites/starter.store#517 ## References <!--- Spread the knowledge: is there any content you used to create this PR that is worth sharing? ---> <!--- Extra tip: adding references to related issues or mentioning people important to this PR may be good for the documentation and reviewing process --->
## What's the purpose of this pull request? This PR aims to correct fuzzy and operator usage when handling Intelligent Search API requests. Previously, we specified a default value for fuzzy `fuzzy=auto`. But we shouldn’t include it on the first request to Search. According to the IS team, the correct behavior should let the search engine decide the best parameters for the search. Re-applies changes made from #2204 without adding the blink effect added previously. - [x] Adds fuzzy & operator parameters in the query - [x] Avoid re-rendering the page - [x] Check search PLP (blink issue) - [x] Check category PLP (blink issue) - [x] Check duplicate `search.query` event to IS ## How it works? More details on #2204 description. ## How to test it? Run the project locally or test though this [preview link](https://sfj-8636169--starter.preview.vtex.app) ### Testing search PLP 1. Search for `apple` using the input search field 2. Open the `Network Tab` and filter for `ClientProductGalleryQuery` - In the first request ->`Response` tab: look for `metadata` object, the `fuzzy` and `logicalOperator` values <img width="1489" alt="image" src="https://github.com/user-attachments/assets/3bc1ccf5-65f9-454a-bddf-8fac768007a9"> - Check if the same values is being set in `selectedFacets` <img width="1227" alt="image" src="https://github.com/user-attachments/assets/383fcf0b-a616-472f-8266-478e145ebaf0"> - You shouldn't see any blink effect in the page in this scenario: https://github.com/user-attachments/assets/c92aec29-d089-45d0-a1d0-8bc991c97bb1 ### Testing in Category PLP 1. Click on `Technology` category 2. You shouldn't see any blink effect in the page in this scenario ### Duplicate Search event in PLP 1. Search for `apple` using the input search field (at once) 2. Open the `Network Tab` and filter for `event` 3. You shouldn't be able to see the event (with the same url and term) being send twice <img width="1574" alt="image" src="https://github.com/user-attachments/assets/7f0607ac-02cf-4c1d-b201-1cddc5000677"> ### Starters Deploy Preview vtex-sites/starter.store#617 ## References #2204 --------- Co-authored-by: Fanny Chien <[email protected]> Co-authored-by: Fanny Chien <[email protected]>
What's the purpose of this pull request?
This PR aims to correct fuzzy and operator usage when handling Intelligent Search API requests.
Previously, we specified a default value for fuzzy
fuzzy=auto
. But we shouldn’t include it on the first request to Search. According to the IS team, the correct behavior should let the search engine decide the best parameters for the search.How it works?
At the beginning of a search, requests should not define fuzzy and operator parameters. The request response will return the parameters selected for this search.
Example:
Request
https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/facets/trade-policy/1?page=1&count=12&query=awe&sort=&locale=en-US&hideUnavailableItems=false
Response
Then, we should apply these parameters when refining the search result; in our context, it should cover two cases:
Request
https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=12&query=awe&sort=&locale=en-US&hideUnavailableItems=false&fuzzy=auto&operator=and
The implemented approach here involves passing the necessary parameters, in the form of facets, after the initial request and using their structure.
How to test it?
Use this preview link to test the following scenarios:
** scenario 1: Search Catergory**
office
categoryClientProductGalleryQuery
preview
tab, search for themetadata
field in datafuzzy
andlogicalOperator
values should correspond to the values in the url, ex:?category-1=office&fuzzy=0&operator=and&
Load More Products
button), the parameters should persist.** scenario 2: Search for a term**
awe
and enterStarters Deploy Preview
https://sfj-320f502--starter.preview.vtex.app/
References