Skip to content

Sort by

Sarah Dayan edited this page Jul 28, 2020 · 4 revisions

Algolia sorts search results by relevance, using its ranking formula. Yet, you can provide several sorting options based on a specific attribute (e.g., descending price) using replica indices.

The sorts configuration lets you display a list of sorting options (via replica indices), allowing users to change the way hits are sorted.

Note that all indices you add must be replicas of the main index you defined as your indexName.

sorts

object[]

A list of sorting options:

Key Type Description
label string The label to display for the index.
value string The Algolia index name to target.

Example with two additional sortings:

export const sorts = [
  {
    label: 'Price ascending',
    value: 'instant_search_price_asc',
  },
  {
    label: 'Price descending',
    value: 'instant_search_price_desc',
  },
];

Example with no additional sorting:

export const sorts = [];