All settings
Index settings are represented as a JSON object literal (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:
- Displayed attributes
- Distinct attribute
- Filterable attributes
- Ranking rules
- Searchable attributes
- Sortable attributes
- Stop-words
- Synonyms
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
/indexes/:index_uid/settings
Get the settings of an index.
Learn more about the settings.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Response body
Variable | Type | Description | Default value |
---|---|---|---|
displayedAttributes | [Strings] | Fields displayed in the returned documents | [““] (all attributes) |
distinctAttribute | String | Search returns documents with distinct (different) values of the given field | null |
filterableAttributes | [Strings] | Attributes to use as filters and facets | [] |
rankingRules | [Strings] | List of ranking rules sorted by order of importance | A 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 | [] |
synonyms | Object | List of associated words treated similarly | {} |
Learn more about the settings in this guide.
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X GET 'http://localhost:7700/indexes/movies/settings'
client.index('movies').getSettings()
client.index('movies').get_settings()
$client->index('movies')->getSettings();
client.index("movies").getSettings();
client.index('movies').settings
client.Index("movies").GetSettings()
let settings: Settings = movies.get_settings().await.unwrap();
client.index("movies").getSettings { (result: Result<Setting, Swift.Error>) in
switch result {
case .success(let setting):
print(setting)
case .failure(let error):
print(error)
}
}
await client.index('movies').getSettings();
Response: 200 Ok
List the settings.
{
"rankingRules": [
"typo",
"words",
"proximity",
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)"
],
"filterableAttributes": [
"genres"
],
"distinctAttribute": null,
"searchableAttributes": [
"title",
"description",
"genres"
],
"displayedAttributes": [
"title",
"description",
"genre",
"release_date"
],
"stopWords": null,
"synonyms": {
"wolverine": [
"xmen",
"logan"
],
"logan": [
"wolverine",
"xmen"
]
}
}
Update settings
POST
/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
Variable | Description |
---|---|
index_uid | The index UID |
Body
Variable | Type | Description | Default value |
---|---|---|---|
displayedAttributes | [Strings] | Fields displayed in the returned documents | [““] (all attributes) |
distinctAttribute | String | Search returns documents with distinct (different) values of the given field | null |
filterableAttributes | [Strings] | Attributes to use as filters and facets | [] |
rankingRules | [Strings] | List of ranking rules sorted by order of importance | A 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 | [] |
synonyms | Object | List of associated words treated similarly | {} |
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X POST 'http://localhost:7700/indexes/movies/settings' \
-H 'Content-Type: application/json' \
--data-binary '{
"rankingRules": [
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:desc",
"rank:desc"
],
"distinctAttribute": "movie_id",
"searchableAttributes": [
"title",
"description",
"genre"
],
"displayedAttributes": [
"title",
"description",
"genre",
"release_date"
],
"stopWords": [
"the",
"a",
"an"
],
"sortableAttributes": [
"title",
"release_date"
],
"synonyms": {
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"]
}
}'
client.index('movies').updateSettings({
rankingRules: [
'words',
'typo',
'proximity',
'attribute',
'sort',
'exactness',
'release_date:desc',
'rank:desc'
],
distinctAttribute: 'movie_id',
searchableAttributes: [
'title',
'description',
'genre'
],
displayedAttributes: [
'title',
'description',
'genre',
'release_date'
],
stopWords: [
'the',
'a',
'an'
],
sortableAttributes: [
'title',
'release_date'
],
synonyms: {
'wolverine': ['xmen', 'logan'],
'logan': ['wolverine']
}
})
client.index('movies').update_settings({
'rankingRules': [
'words',
'typo',
'proximity',
'attribute',
'sort',
'exactness',
'release_date:desc',
'rank:desc'
],
'distinctAttribute': 'movie_id',
'searchableAttributes': [
'title',
'description',
'genre'
],
'displayedAttributes': [
'title',
'description',
'genre',
'release_date'
],
'sortableAttributes': [
'title',
'release_date'
],
'stopWords': [
'the',
'a',
'an'
],
'synonyms': {
'wolverine': ['xmen', 'logan'],
'logan': ['wolverine']
},
'acceptNewFields': False
})
$client->index('movies')->updateSettings([
'rankingRules' => [
'words',
'typo',
'proximity',
'attribute',
'sort',
'exactness',
'release_date:desc',
'rank:desc'
],
'distinctAttribute' => 'movie_id',
'searchableAttributes' => [
'title',
'description',
'genre'
],
'displayedAttributes' => [
'title',
'description',
'genre',
'release_date'
],
'stopWords' => [
'the',
'a',
'an'
],
'sortableAttributes' => [
'title',
'release_date'
],
'synonyms' => [
'wolverine' => ['xmen', 'logan'],
'logan' => ['wolverine']
]
]);
Settings settings = new Settings();
settings.setRankingRules(
new String[] {
"typo",
"words",
"sort",
"proximity",
"attribute",
"exactness",
"release_date:desc",
"rank:desc"
});
settings.setDistinctAttribute("movie_id");
settings.setSearchableAttributes(
new String[] {
"title",
"description",
"genre",
});
settings.setDisplayedAttributes(
new String[] {
"title",
"description",
"genre",
"release_date",
});
settings.setStopWords(
new String[] {
"the",
"a",
"an",
});
settings.setSortableAttributes(
new String[] {
"title",
"release_date",
});
HashMap<String, String[]> synonyms = new HashMap<String, String[]>();
synonyms.put("wolverine", new String[] {"xmen", "logan"});
synonyms.put("logan", new String[] {"wolverine"});
settings.setSynonyms(synonyms);
client.index("movies").updateSettings(settings);
client.index('movies').update_settings({
ranking_rules: [
'words',
'typo',
'proximity',
'attribute',
'sort',
'exactness',
'release_date:desc',
'rank:desc'
],
distinct_attribute: 'movie_id',
searchable_attributes: [
'title',
'description',
'genre'
],
displayed_attributes: [
'title',
'description',
'genre',
'release_date'
],
stop_words: [
'the',
'a',
'an'
],
sortable_attributes: [
'title',
'release_date'
],
synonyms: {
wolverine: ['xmen', 'logan'],
logan: ['wolverine']
}
})
distinctAttribute := "movie_id"
settings := meilisearch.Settings{
RankingRules: []string{
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:desc",
"rank:desc",
},
DistinctAttribute: &distinctAttribute,
SearchableAttributes: []string{
"title",
"description",
"genre",
},
DisplayedAttributes: []string{
"title",
"description",
"genre",
"release_date",
},
StopWords: []string{
"the",
"a",
"an",
},
SortableAttributes: []string{
"title",
"release_date",
},
Synonyms: map[string][]string{
"wolverine": []string{"xmen", "logan"},
"logan": []string{"wolverine"},
},
}
client.Index("movies").UpdateSettings(&settings)
let mut synonyms = std::collections::HashMap::new();
synonyms.insert(String::from("wolverine"), vec!["xmen", "logan"]);
synonyms.insert(String::from("logan"), vec!["wolverine"]);
let settings = Settings::new()
.with_ranking_rules([
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:desc",
"rank:desc"
])
.with_distinct_attribute("movie_id")
.with_searchable_attributes([
"title",
"description",
"genre"
])
.with_displayed_attributes([
"title",
"description",
"genre",
"release_date"
])
.with_stop_words([
"the",
"a",
"an"
])
.with_sortable_attributes([
"title",
"release_date"
])
.with_synonyms(synonyms);
let progress: Progress = movies.set_settings(&settings).await.unwrap();
let settings = Setting(rankingRules: [
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:desc",
"rank:desc"
], searchableAttributes: [
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank"
], displayedAttributes: [
"title",
"description",
"poster",
"release_date",
"rank"
], stopWords: [
"the",
"a",
"an"
], sortableAttributes: [
"title",
"release_date"
], synonyms: [
"wolverine": ["xmen", "logan"],
"logan": ["wolverine"]
])
client.index("movies").updateSettings(settings) { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('movies').updateSettings(IndexSettings(
rankingRules: [
'words',
'typo',
'proximity',
'attribute',
'sort',
'exactness',
'release_date:desc',
'rank:desc'
],
distinctAttribute: 'movie_id',
searchableAttributes: ['title', 'description', 'genre'],
displayedAttributes: ['title', 'description', 'genre', 'release_date'],
stopWords: ['the', 'a', 'an'],
sortableAttributes: ['title', 'release_date'],
synonyms: {
'wolverine': ['xmen', 'logan'],
'logan': ['wolverine'],
},
));
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.
Reset settings
DELETE
/indexes/:index_uid/settings
Reset the settings of an index.
All settings will be reset to their default value.
Variable | Type | Description | Default value |
---|---|---|---|
displayedAttributes | [Strings] | Fields displayed in the returned documents | [““] (all attributes) |
distinctAttribute | String | Search returns documents with distinct (different) values of the given field | null |
filterableAttributes | [Strings] | Attributes to use as filters and facets | [] |
rankingRules | [Strings] | List of ranking rules sorted by order of importance | A 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 | [] |
synonyms | Object | List of associated words treated similarly | {} |
Learn more about the settings.
Path variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
<>
cURL
JS
Python
PHP
Java
Ruby
Go
Rust
Swift
Dart
curl \
-X DELETE 'http://localhost:7700/indexes/movies/settings'
client.index('movies').resetSettings()
client.index('movies').reset_settings()
$client->index('movies')->resetSettings();
client.index("movies").resetSettings();
client.index('movies').reset_settings
client.Index("movies").ResetSettings()
let progress: Progress = movies.reset_settings().await.unwrap();
client.index("movies").resetSettings { (result: Result<Update, Swift.Error>) in
switch result {
case .success(let update):
print(update)
case .failure(let error):
print(error)
}
}
await client.index('movies').resetSettings();
Response: 202 Accepted
{ "updateId": 1 }
This updateId
allows you to track the current update.