All settings

Index settings are represented as a JSON object literalAll Settings - 图1 (opens new window), containing a field for each possible customization option.

It is possible to modify all the settings at once using the update settings endpoint, or individually using the dedicated routes.

These are the reference pages for the dedicated routes:

To learn more about settings, refer to our dedicated guide.

WARNING

When you update a setting, you overwrite its default value. Use the DELETE route to reset any setting to its original value.

Get settings

GET

  1. /indexes/:index_uid/settings

Get the settings of an index.

Learn more about the settings.

Path variables

VariableDescription
index_uidThe index UID

Response body

VariableTypeDescriptionDefault value
displayedAttributes[Strings]Fields displayed in the returned documents[““] (all attributes)
distinctAttributeStringSearch returns documents with distinct (different) values of the given fieldnull
filterableAttributes[Strings]Attributes to use as filters and facets[]
rankingRules[Strings]List of ranking rules sorted by order of importanceA list of ordered built-in ranking rules
searchableAttributes[Strings]Fields in which to search for matching query words sorted by order of importance[““] (all attributes)
sortableAttributes[Strings]Attributes to use when sorting search results[]
stopWords[Strings]List of words ignored by MeiliSearch when present in search queries[]
synonymsObjectList of associated words treated similarly{}

Learn more about the settings in this guide.

Example

<>

cURL

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

  1. curl \
  2. -X GET 'http://localhost:7700/indexes/movies/settings'
  1. client.index('movies').getSettings()
  1. client.index('movies').get_settings()
  1. $client->index('movies')->getSettings();
  1. client.index("movies").getSettings();
  1. client.index('movies').settings
  1. client.Index("movies").GetSettings()
  1. let settings: Settings = movies.get_settings().await.unwrap();
  1. client.index("movies").getSettings { (result: Result<Setting, Swift.Error>) in
  2. switch result {
  3. case .success(let setting):
  4. print(setting)
  5. case .failure(let error):
  6. print(error)
  7. }
  8. }
  1. await client.index('movies').getSettings();

Response: 200 Ok

List the settings.

  1. {
  2. "rankingRules": [
  3. "typo",
  4. "words",
  5. "proximity",
  6. "attribute",
  7. "wordsPosition",
  8. "exactness",
  9. "desc(release_date)"
  10. ],
  11. "filterableAttributes": [
  12. "genres"
  13. ],
  14. "distinctAttribute": null,
  15. "searchableAttributes": [
  16. "title",
  17. "description",
  18. "genres"
  19. ],
  20. "displayedAttributes": [
  21. "title",
  22. "description",
  23. "genre",
  24. "release_date"
  25. ],
  26. "stopWords": null,
  27. "synonyms": {
  28. "wolverine": [
  29. "xmen",
  30. "logan"
  31. ],
  32. "logan": [
  33. "wolverine",
  34. "xmen"
  35. ]
  36. }
  37. }

Update settings

POST

  1. /indexes/:index_uid/settings

Update the settings of an index.

Passing null to an index setting will reset it to its default value.

Updates in the settings route are partial. This means that any parameters not provided in the body will be left unchanged.

If the provided index does not exist, it will be created.

Learn more about the settings in this guide.

Path variables

VariableDescription
index_uidThe index UID

Body

VariableTypeDescriptionDefault value
displayedAttributes[Strings]Fields displayed in the returned documents[““] (all attributes)
distinctAttributeStringSearch returns documents with distinct (different) values of the given fieldnull
filterableAttributes[Strings]Attributes to use as filters and facets[]
rankingRules[Strings]List of ranking rules sorted by order of importanceA list of ordered built-in ranking rules
searchableAttributes[Strings]Fields in which to search for matching query words sorted by order of importance[““] (all attributes)
sortableAttributes[Strings]Attributes to use when sorting search results[]
stopWords[Strings]List of words ignored by MeiliSearch when present in search queries[]
synonymsObjectList of associated words treated similarly{}

Example

<>

cURL

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings' \
  3. -H 'Content-Type: application/json' \
  4. --data-binary '{
  5. "rankingRules": [
  6. "words",
  7. "typo",
  8. "proximity",
  9. "attribute",
  10. "sort",
  11. "exactness",
  12. "release_date:desc",
  13. "rank:desc"
  14. ],
  15. "distinctAttribute": "movie_id",
  16. "searchableAttributes": [
  17. "title",
  18. "description",
  19. "genre"
  20. ],
  21. "displayedAttributes": [
  22. "title",
  23. "description",
  24. "genre",
  25. "release_date"
  26. ],
  27. "stopWords": [
  28. "the",
  29. "a",
  30. "an"
  31. ],
  32. "sortableAttributes": [
  33. "title",
  34. "release_date"
  35. ],
  36. "synonyms": {
  37. "wolverine": ["xmen", "logan"],
  38. "logan": ["wolverine"]
  39. }
  40. }'
  1. client.index('movies').updateSettings({
  2. rankingRules: [
  3. 'words',
  4. 'typo',
  5. 'proximity',
  6. 'attribute',
  7. 'sort',
  8. 'exactness',
  9. 'release_date:desc',
  10. 'rank:desc'
  11. ],
  12. distinctAttribute: 'movie_id',
  13. searchableAttributes: [
  14. 'title',
  15. 'description',
  16. 'genre'
  17. ],
  18. displayedAttributes: [
  19. 'title',
  20. 'description',
  21. 'genre',
  22. 'release_date'
  23. ],
  24. stopWords: [
  25. 'the',
  26. 'a',
  27. 'an'
  28. ],
  29. sortableAttributes: [
  30. 'title',
  31. 'release_date'
  32. ],
  33. synonyms: {
  34. 'wolverine': ['xmen', 'logan'],
  35. 'logan': ['wolverine']
  36. }
  37. })
  1. client.index('movies').update_settings({
  2. 'rankingRules': [
  3. 'words',
  4. 'typo',
  5. 'proximity',
  6. 'attribute',
  7. 'sort',
  8. 'exactness',
  9. 'release_date:desc',
  10. 'rank:desc'
  11. ],
  12. 'distinctAttribute': 'movie_id',
  13. 'searchableAttributes': [
  14. 'title',
  15. 'description',
  16. 'genre'
  17. ],
  18. 'displayedAttributes': [
  19. 'title',
  20. 'description',
  21. 'genre',
  22. 'release_date'
  23. ],
  24. 'sortableAttributes': [
  25. 'title',
  26. 'release_date'
  27. ],
  28. 'stopWords': [
  29. 'the',
  30. 'a',
  31. 'an'
  32. ],
  33. 'synonyms': {
  34. 'wolverine': ['xmen', 'logan'],
  35. 'logan': ['wolverine']
  36. },
  37. 'acceptNewFields': False
  38. })
  1. $client->index('movies')->updateSettings([
  2. 'rankingRules' => [
  3. 'words',
  4. 'typo',
  5. 'proximity',
  6. 'attribute',
  7. 'sort',
  8. 'exactness',
  9. 'release_date:desc',
  10. 'rank:desc'
  11. ],
  12. 'distinctAttribute' => 'movie_id',
  13. 'searchableAttributes' => [
  14. 'title',
  15. 'description',
  16. 'genre'
  17. ],
  18. 'displayedAttributes' => [
  19. 'title',
  20. 'description',
  21. 'genre',
  22. 'release_date'
  23. ],
  24. 'stopWords' => [
  25. 'the',
  26. 'a',
  27. 'an'
  28. ],
  29. 'sortableAttributes' => [
  30. 'title',
  31. 'release_date'
  32. ],
  33. 'synonyms' => [
  34. 'wolverine' => ['xmen', 'logan'],
  35. 'logan' => ['wolverine']
  36. ]
  37. ]);
  1. Settings settings = new Settings();
  2. settings.setRankingRules(
  3. new String[] {
  4. "typo",
  5. "words",
  6. "sort",
  7. "proximity",
  8. "attribute",
  9. "exactness",
  10. "release_date:desc",
  11. "rank:desc"
  12. });
  13. settings.setDistinctAttribute("movie_id");
  14. settings.setSearchableAttributes(
  15. new String[] {
  16. "title",
  17. "description",
  18. "genre",
  19. });
  20. settings.setDisplayedAttributes(
  21. new String[] {
  22. "title",
  23. "description",
  24. "genre",
  25. "release_date",
  26. });
  27. settings.setStopWords(
  28. new String[] {
  29. "the",
  30. "a",
  31. "an",
  32. });
  33. settings.setSortableAttributes(
  34. new String[] {
  35. "title",
  36. "release_date",
  37. });
  38. HashMap<String, String[]> synonyms = new HashMap<String, String[]>();
  39. synonyms.put("wolverine", new String[] {"xmen", "logan"});
  40. synonyms.put("logan", new String[] {"wolverine"});
  41. settings.setSynonyms(synonyms);
  42. client.index("movies").updateSettings(settings);
  1. client.index('movies').update_settings({
  2. ranking_rules: [
  3. 'words',
  4. 'typo',
  5. 'proximity',
  6. 'attribute',
  7. 'sort',
  8. 'exactness',
  9. 'release_date:desc',
  10. 'rank:desc'
  11. ],
  12. distinct_attribute: 'movie_id',
  13. searchable_attributes: [
  14. 'title',
  15. 'description',
  16. 'genre'
  17. ],
  18. displayed_attributes: [
  19. 'title',
  20. 'description',
  21. 'genre',
  22. 'release_date'
  23. ],
  24. stop_words: [
  25. 'the',
  26. 'a',
  27. 'an'
  28. ],
  29. sortable_attributes: [
  30. 'title',
  31. 'release_date'
  32. ],
  33. synonyms: {
  34. wolverine: ['xmen', 'logan'],
  35. logan: ['wolverine']
  36. }
  37. })
  1. distinctAttribute := "movie_id"
  2. settings := meilisearch.Settings{
  3. RankingRules: []string{
  4. "words",
  5. "typo",
  6. "proximity",
  7. "attribute",
  8. "sort",
  9. "exactness",
  10. "release_date:desc",
  11. "rank:desc",
  12. },
  13. DistinctAttribute: &distinctAttribute,
  14. SearchableAttributes: []string{
  15. "title",
  16. "description",
  17. "genre",
  18. },
  19. DisplayedAttributes: []string{
  20. "title",
  21. "description",
  22. "genre",
  23. "release_date",
  24. },
  25. StopWords: []string{
  26. "the",
  27. "a",
  28. "an",
  29. },
  30. SortableAttributes: []string{
  31. "title",
  32. "release_date",
  33. },
  34. Synonyms: map[string][]string{
  35. "wolverine": []string{"xmen", "logan"},
  36. "logan": []string{"wolverine"},
  37. },
  38. }
  39. client.Index("movies").UpdateSettings(&settings)
  1. let mut synonyms = std::collections::HashMap::new();
  2. synonyms.insert(String::from("wolverine"), vec!["xmen", "logan"]);
  3. synonyms.insert(String::from("logan"), vec!["wolverine"]);
  4. let settings = Settings::new()
  5. .with_ranking_rules([
  6. "words",
  7. "typo",
  8. "proximity",
  9. "attribute",
  10. "sort",
  11. "exactness",
  12. "release_date:desc",
  13. "rank:desc"
  14. ])
  15. .with_distinct_attribute("movie_id")
  16. .with_searchable_attributes([
  17. "title",
  18. "description",
  19. "genre"
  20. ])
  21. .with_displayed_attributes([
  22. "title",
  23. "description",
  24. "genre",
  25. "release_date"
  26. ])
  27. .with_stop_words([
  28. "the",
  29. "a",
  30. "an"
  31. ])
  32. .with_sortable_attributes([
  33. "title",
  34. "release_date"
  35. ])
  36. .with_synonyms(synonyms);
  37. let progress: Progress = movies.set_settings(&settings).await.unwrap();
  1. let settings = Setting(rankingRules: [
  2. "words",
  3. "typo",
  4. "proximity",
  5. "attribute",
  6. "sort",
  7. "exactness",
  8. "release_date:desc",
  9. "rank:desc"
  10. ], searchableAttributes: [
  11. "uid",
  12. "movie_id",
  13. "title",
  14. "description",
  15. "poster",
  16. "release_date",
  17. "rank"
  18. ], displayedAttributes: [
  19. "title",
  20. "description",
  21. "poster",
  22. "release_date",
  23. "rank"
  24. ], stopWords: [
  25. "the",
  26. "a",
  27. "an"
  28. ], sortableAttributes: [
  29. "title",
  30. "release_date"
  31. ], synonyms: [
  32. "wolverine": ["xmen", "logan"],
  33. "logan": ["wolverine"]
  34. ])
  35. client.index("movies").updateSettings(settings) { (result: Result<Update, Swift.Error>) in
  36. switch result {
  37. case .success(let update):
  38. print(update)
  39. case .failure(let error):
  40. print(error)
  41. }
  42. }
  1. await client.index('movies').updateSettings(IndexSettings(
  2. rankingRules: [
  3. 'words',
  4. 'typo',
  5. 'proximity',
  6. 'attribute',
  7. 'sort',
  8. 'exactness',
  9. 'release_date:desc',
  10. 'rank:desc'
  11. ],
  12. distinctAttribute: 'movie_id',
  13. searchableAttributes: ['title', 'description', 'genre'],
  14. displayedAttributes: ['title', 'description', 'genre', 'release_date'],
  15. stopWords: ['the', 'a', 'an'],
  16. sortableAttributes: ['title', 'release_date'],
  17. synonyms: {
  18. 'wolverine': ['xmen', 'logan'],
  19. 'logan': ['wolverine'],
  20. },
  21. ));

Response: 202 Accepted

  1. { "updateId": 1 }

This updateId allows you to track the current update.

Reset settings

DELETE

  1. /indexes/:index_uid/settings

Reset the settings of an index.

All settings will be reset to their default value.

VariableTypeDescriptionDefault value
displayedAttributes[Strings]Fields displayed in the returned documents[““] (all attributes)
distinctAttributeStringSearch returns documents with distinct (different) values of the given fieldnull
filterableAttributes[Strings]Attributes to use as filters and facets[]
rankingRules[Strings]List of ranking rules sorted by order of importanceA list of ordered built-in ranking rules
searchableAttributes[Strings]Fields in which to search for matching query words sorted by order of importance[““] (all attributes)
sortableAttributes[Strings]Attributes to use when sorting search results[]
stopWords[Strings]List of words ignored by MeiliSearch when present in search queries[]
synonymsObjectList of associated words treated similarly{}

Learn more about the settings.

Path variables

VariableDescription
index_uidThe index UID

Example

<>

cURL

JS

Python

PHP

Java

Ruby

Go

Rust

Swift

Dart

  1. curl \
  2. -X DELETE 'http://localhost:7700/indexes/movies/settings'
  1. client.index('movies').resetSettings()
  1. client.index('movies').reset_settings()
  1. $client->index('movies')->resetSettings();
  1. client.index("movies").resetSettings();
  1. client.index('movies').reset_settings
  1. client.Index("movies").ResetSettings()
  1. let progress: Progress = movies.reset_settings().await.unwrap();
  1. client.index("movies").resetSettings { (result: Result<Update, Swift.Error>) in
  2. switch result {
  3. case .success(let update):
  4. print(update)
  5. case .failure(let error):
  6. print(error)
  7. }
  8. }
  1. await client.index('movies').resetSettings();

Response: 202 Accepted

  1. { "updateId": 1 }

This updateId allows you to track the current update.