Skip to main content
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 relevance and custom ranking. It’s intended for use cases requiring strict sorting or where relevance isn’t essential, like an inventory app or a database. An alternative to exhaustive sorting is relevant sorting.

Effect on ranking formula

In Algolia, each of your indices has a ranking formula of two or three parts:

Sort-by attribute

If a sort-by attribute is present, Algolia first orders results by the sort-by attribute’s value. For example, suppose you have an where you’ve set “price (ascending)” as a sort-by attribute. For the iphone, Algolia first selects all that match iphone (and alternatives like prefixes, typos, and synonyms) in the searchableAttributes. Then, it orders the results from lowest to highest price.
  • After sorting by the sort-by attribute’s value (price), Algolia applies its default textual ranking criteria to records with the same price.
  • If records have the same values for all textual ranking criteria, Algolia orders them by custom ranking.
In summary, textual ranking criteria come after your selected sort-by attribute. With exhaustive sorting, textual ranking criteria have little effect if the sort-by attribute values are sufficiently granular or unique. For example, consider exhaustively sorting on a timestamp attribute down to the millisecond. If none of your records have the same timestamp value, the timestamp is the only attribute that plays a role in ranking. If this is the intended behavior, no further changes are needed. Otherwise, reduce the timestamp granularity or use relevant sorting instead. To learn more, see:

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. Screenshot of a 'SortBy' drop-down menu showing options for 'Relevance', 'Price ascending', and 'Price desc.'.

Sorting and optional filters

Optional filters are applied after the sort-by attribute. Therefore, you can’t use rules to boost or bury records with indices with sort-by attributes.
Last modified on September 16, 2026