# Settings

# Get index settings

GET
/indexes/:uid/settings

Get settings for a given index.

# Path Variables

Variable Description
uid The index name

# Example

$ curl \
  -X GET 'http://localhost:7700/indexes/12345678/settings'

# Response: 200 Ok

List the settings.

{
  "rankingOrder": [
    "_sum_of_typos",
    "_number_of_words",
    "_word_proximity",
    "_sum_of_words_attribute",
    "_sum_of_words_position",
    "_exact",
    "release_date"
  ],
  "distinctField": "",
  "rankingRules": {
    "release_date": "dsc"
  }
}

# Add or replace index settings

POST
/indexes/:uid/settings

Add or replace the following settings of an index:

# Path Variables

Variable Description
uid The index name

# Body

Variable Description
rankingRules All custom ranking rules
rankingOrder Ranking order of all rules, custom and default
distinct Field to which distinct will be applied

# Ranking rules

An objet containing document attributes as keys and asc ascending or dsc descending as value of this key. More information about custom ranking rules.

WARNING

To activate a ranking rule on a field, this field must have the ranked property in the schema and it must be in the ranking order.

# Ranking order

A list of ranking rules ordered by importance for the bucket sort. The first rule being the most important.

# Distinct field

A string containing the attribute that needs to be distinct.

NOTE

None of the 3 settings parameters are mandatory

# Examples

# Add settings

$ curl \
  -X GET 'http://localhost:7700/indexes/12345678/settings' \
  --data '{
  "rankingOrder": [
    "_sum_of_typos",
    "_number_of_words",
    "_word_proximity",
    "_sum_of_words_attribute",
    "_sum_of_words_position",
    "_exact",
    "release_date"
  ],
  "rankingRules": {
    "release_date": "dsc"
  }
}'

# Set back the default MeiliSearch settings

$ curl \
  -X GET 'http://localhost:7700/indexes/12345678/settings' \
  --data '{
  "rankingOrder": null,
  "distinctField": null,
  "rankingRules": null
}'

WARNING

You must set the fields to null to reset them and not to the empty value.
Setting the fields to [], {} or "" will erase all rules, even the MeiliSearch default behavior.

# Response: 202 Accepted

{
  "updateId": 1
}

This updateId allows you to track the current update.