Effect on ranking formula
In Algolia, each of your indices has a ranking formula of two or three parts:- Sort-by attributes (optional)
- Textual ranking criteria
- Custom ranking, also known as business ranking criteria
Sort-by attribute
You should only add a sort-by attribute to replica indices.
searchableAttributes
. Then, it orders the results from lowest to highest price.
- Once sorted by the sort-by attribute’s value (price), products with the same price are ordered according to Algolia’s default textual ranking criteria.
- If records have the same values for all textual ranking criteria, the engine orders them by custom ranking.
Backend implementation
To ensure a fast search experience, the engine sorts your data at indexing time. Therefore, each of your indices can only be sorted in one way. However, to allow for multiple sort orders, Algolia uses replica indices.Exhaustive sorting uses standard index replicas
A replica is a copy of one of your indices, with the same data and synchronized data updates, but can have unique settings. The index from which you copy a replica’s data is the replica’s primary index. If you want to configure an exhaustive sort-by, use standard replicas. For each attribute you want to sort by, create a replica index, which contains a copy of all the data in your primary index.Frontend implementation
Replica indices manage the backend of sorting, but you still need to implement the frontend with custom logic or InstantSearch’s SortBy UI widget.