On this page
The Relevant sort feature selects a group of relevant results and sorts them to remove less relevant results included in an exhaustive sort. In most use cases, it removes the noise and provides a more user-friendly experience, since it shows users the most relevant results.
Relevant sorting leverages virtual replicas. Unlike standard replicas, virtual replicas don’t duplicate the primary’s record. Instead, a virtual replica can be seen as a “view” of the primary index. As a result, it reuses the primary’s ranking formula to return relevant results.
This feature is only available to Premium plans.
Effect on ranking formula
When you sort by attribute, Algolia’s ranking formula isn’t turned off; instead, the Relevant sorting algorithm uses its primary index ranking formula to select the relevant results. The algorithm picks the group of relevant results thanks to a similarity formula based on the ranking criteria:
- Select records matching the query with the help of the primary index ranking formula
- Select the hits that are in the
- Sort and return the relevant results
You can configure the Relevant sort’s behavior with the
relevancyStrictness parameter. This parameter controls how strict the algorithm should be in the selection of the results.
If multiple hits have the same value for the sorting attribute, then the tie-breaking approach proceeds as usual on the defined sorting attributes. For example, suppose you’ve sorted by price and then by popularity. If a query yields three records that cost $99, then the engine further orders them by their popularity attribute.
Relevant sorting considerations
Relevant sorting interacts with other features in ways you might not expect.
Incoherent behaviors with other re-ranking features
Using the Relevant sort feature with other re-ranking features can lead to disjointed results. For example, if Personalization promotes expensive items for a particular user based on their past actions, that user might see expensive items at the top of the results, though they’ve selected to Relevant sort from lowest to highest price.
You shouldn’t use the following features or parameters with Relevant sorts:
The engine applies Rules after ranking and sorting so that they keep working as expected.
When the Relevant sorting feature is enabled, the engine still computes facets on the whole results set, not the one refined by the Relevant sort. A UI banner detailing the behavior of the Relevant sort helps managing the user’s expectations.
Virtual replicas indices manage the back end of sorting, but you still need to implement the front end. You can do this with either custom logic or InstantSearch.
If you’re using InstantSearch, you should use the
sortBy UI widget to let your users sort.
To make sure the user understands the behavior and keep the control over their experience, a best practice is to be transparent and display that the sort removed some results but keep the possibility to display more results. You can do this with the
relevantSort UI widget.