-
Notifications
You must be signed in to change notification settings - Fork 531
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(smartSort): add widget #4648
Conversation
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 777e47d:
|
This reverts commit 996c09a.
Co-authored-by: Haroen Viaene <hello@haroen.me>
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.
🔥
Co-authored-by: Haroen Viaene <hello@haroen.me>
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.
🚀
}>; | ||
|
||
export type SmartSortTemplates = Partial<{ | ||
text: string | (({ isSmartSorted }: { isSmartSorted: boolean }) => string); |
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.
There's the Template
type to handle those.
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.
Good catch d54831c
Summary
This PR adds the
smartSort
widget.When "Smart Sort" is enabled, the engine will not provide all the results, but a subset of relevant hits.
For example, when you search for "iPhone" and sort by low price, you probably get iPhone cables, because they're cheap.
However in the context of Smart Sort, you will get real iPhone products although the total number of hits will be much less than the former.
How to enable Smart Sort?
relevancyStrictness
value on Algolia dashboardHow do we know the results is smartly sorted?
The search response will contain
appliedRelevancyStrictness
property (optional). If it exists and greater than 00, it means it's smartly sorted. If it's 0 or doesn't exist, then it's traditional sort.What does this widget do?
The widget will display a button saying either "See all results" or "See relevant results". It depends if the current results are smartly sorted or not.
If a user clicks the button because they want to see all the results regardless of smart sort, the widget will attach
relevancyStrictness=0
to the search parameter.If clicked again, it will go back to the previous value (given by widgetParams, either a value or undefined).