# Ranking rules

Child route of the settings route.

Ranking rules are built-in rules that allow you to customize the relevancy of your search results. They are stored in an array and applied in order of appearance.

Ranking rules can also be updated directly through the global settings route along with the other settings.

Learn more about ranking rules.

NOTE

Updating the settings means overwriting the default settings of MeiliSearch. You can reset to default values using the DELETE routes.

# Get ranking rules

GET
/indexes/:index_uid/settings/ranking-rules

Get the ranking rules of an index.

# Path variables

Variable Description
index_uid The index UID

# Default value

An array that contains ranking rules in order of importance.

# Example

# Response: 200 Ok

List the settings.

[
  "words",
  "typo",
  "proximity",
  "attribute",
  "sort",
  "exactness",
  "release_date:desc"
]

# Update ranking rules

POST
/indexes/:index_uid/settings/ranking-rules

Update the ranking rules of an index.

# Path variables

Variable Description
index_uid The index UID

# Body

An array that contain ranking rules sorted by order of importance.

To add your own ranking rule, you have to communicate an attribute followed by a colon (:) and either asc for ascending order or desc for descending order.

  • To apply an ascending sort (results sorted by increasing value): attribute_name:asc

  • To apply a descending sort (results sorted by decreasing value): attribute_name:desc

More information about the body.

# Example

# Response: 202 Accepted

{
  "updateId": 1
}

This updateId allows you to track the current update.

# Reset ranking rules

DELETE
/indexes/:index_uid/settings/ranking-rules

Reset the ranking rules of an index to their default value.

TIP

Note that resetting the ranking rules is not the same as removing them.
To remove a ranking rule, use the add or replace ranking rules route.

# Default value

An array that contains the built-in ranking rules in the following order:

[
  "words", 
  "typo", 
  "proximity", 
  "attribute", 
  "sort",
  "exactness"
]

# Path Variables

Variable Description
index_uid The index UID

# Example

# Response: 202 Accepted

{
  "updateId": 1
}

This updateId allows you to track the current update.