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(smartSort): add widget #4648

Merged
merged 30 commits into from
Feb 22, 2021
Merged

feat(smartSort): add widget #4648

merged 30 commits into from
Feb 22, 2021

Conversation

eunjae-lee
Copy link
Contributor

@eunjae-lee eunjae-lee commented Feb 10, 2021

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?

  1. You can configure your index to have relevancyStrictness value on Algolia dashboard

How 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?

smartSort({ container: "#smart-sort" });

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).

@eunjae-lee eunjae-lee changed the title chore: update types feat(smartSort): add widget Feb 10, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 10, 2021

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:

Sandbox Source
InstantSearch.js Configuration

@eunjae-lee eunjae-lee marked this pull request as ready for review February 15, 2021 09:51
Eunjae Lee and others added 2 commits February 16, 2021 17:17
Copy link
Contributor

@Haroenv Haroenv left a 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>
@eunjae-lee eunjae-lee requested a review from Haroenv February 18, 2021 14:53
Copy link
Member

@shortcuts shortcuts left a 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);
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch d54831c

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.

4 participants