Skip to main content
  • Type: list<string>
  • Default: [](no custom ranking)
  • Scope: settings
Algolia’s tie-breaking algorithm applies the custom ranking attributes in the order they’re listed. Use asc(attribute) or desc(attribute) to specify the sort direction for each attribute. To learn more, see Custom ranking.

Usage

  • Attribute names are case-sensitive.
  • Records with missing or null values for a custom ranking attribute are considered equal and are placed at the end of the result list, regardless of sort order.
  • Boolean values are sorted alphabetically: false comes before true in ascending order, and true comes before false in descending order.

Modifiers

asc
Sort by increasing value of the attribute.
desc
Sort by decreasing value of the attribute.

Example

The following example ranks tied records by decreasing popularity. Records with equal popularity will be ranked by ascending price.

Current API clients

var response = await client.SetSettingsAsync(
  "ALGOLIA_INDEX_NAME",
  new IndexSettings
  {
    CustomRanking = new List<string> { "desc(popularity)", "asc(price)" },
  }
);
IndexSettings settings = new IndexSettings();

settings.CustomRanking = new List
{
    "desc(popularity)",
    "asc(price)"
};

index.SetSettings(settings);
I