Skip to main content
  • Type: list<string>
  • Default: ["typo", "geo", "words", "filters", "proximity", "attribute", "exact", "custom"]
  • Scope: settings
This setting controls how Algolia sorts your results. The tie-breaking algorithm sequentially applies ranking criteria in the order specified.
You can change the order of the default criteria but you shouldn’t. The out-of-the-box ranking order works for most uses. Before changing this parameter, consider running an A/B test to ensure your changes will positively affect results.

Usage

  • Attribute names are case-sensitive.
  • Add asc(attribute) or desc(attribute) to the list to sort by attributes such as price or popularity.
  • You can reorder or remove criteria to fine-tune ranking, but the default order works well for most situations.
  • Ranking also depends on the order of attributes in searchableAttributes.

Ranking criteria

typo
Rank results by the fewest spelling mistakes.
geo
Rank results by increasing distance. This option only applies when performing a geographical search.
words
Rank results by the number of matching query words, starting with the most matches. Only applies when using optionalWords.
filters
Rank results by filter score. This option is essential when using optionalFilters.
proximity
Rank results by how close the query words are to each other in the record.
attribute
Rank results based on the order of attributes defined in searchableAttributes.
exact
For single-word queries, follows the behavior defined by the exactOnSingleWordQuery setting. For multi-word queries, ranks by number of exact word matches.
custom
Rank results based on the values of attributes listed in customRanking. If not included in ranking, the custom ranking criterion is ignored.

Modifiers

asc
Sort in ascending order (lowest to highest).
desc
Sort in descending order (highest to lowest).

Examples

Current API clients

Use the default ranking

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings
  {
    Ranking = new List<string>
    {
      "typo",
      "geo",
      "words",
      "filters",
      "attribute",
      "proximity",
      "exact",
      "custom",
    },
  }
);

Sort by ascending price

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings
  {
    Ranking = new List<string>
    {
      "asc(price)",
      "typo",
      "geo",
      "words",
      "filters",
      "proximity",
      "attribute",
      "exact",
      "custom",
    },
  }
);

Change default ranking

IndexSettings settings = new IndexSettings();
settings.Ranking = new List
{
    "typo",
    "geo",
    "words",
    "filters",
    "attribute",
    "proximity",
    "exact",
    "custom"
};

index.SetSettings(settings);

Sort by ascending price

IndexSettings settings = new IndexSettings
settings.Ranking = new List
{
    "asc(price)",
    "typo",
    "geo",
    "words",
    "filters",
    "proximity",
    "attribute",
    "exact",
    "custom"
};

index.SetSettings(settings);
I