Standard Replica's with a SortBy attribute perform whats called Exhaustive sorting. Exhaustive sorting refers to strictly reordering results by an attribute. For example, you can exhaustively sort results from lowest to highest price, regardless of textual and business relevance.
If a sort-by attribute is present, the engine first orders results by the sort-by attribute’s value. Once sorted by the sort-by attribute’s value, products with the same value for that attribute are ordered according to Algolia’s default textual ranking criteria. Textual ranking criteria is applied after your selected sort-by attribute.
If you're not looking for strictly sorted results there is an alternative called Relevant sorting that uses Virtual Replicas. With Relevant Sorting, Algolia’s ranking formula isn’t turned off when you sort by an attribute. Instead, the relevant sorting algorithm selects results as follows:
- Selects results matching the user’s query by using the primary index’s ranking formula.
- Selects only the most relevant results. This a threshold set by the
relevancyStrictness
setting. With ‘relevancyStrictness`, you instruct the engine to only return results with that relevancy score or better. At query time, the engine computes a relevancy score of 0-100 for each result (by comparing each hit to the best one, a score of 100). - Sorts the selected results based on the virtual replica’s
customRanking
sorting criteria. - Returns the relevant results.
For more information on the difference between Standard Replicas and Virtual Replicas we recommend our guides on Understanding Replicas and Sorting Results.
Relevant sorting is only available on Premium plans.