Synonyms
Child route of the settings route.
Synonyms
is an object containing words and their respective synonyms. A synonym in Meilisearch is considered equal to its associated word in a search query.
Synonyms can also be updated directly through the global settings route along with the other settings.
NOTE
Updating the settings means overwriting the default settings of MeiliSearch. You can reset to default values using the DELETE
routes.
Get synonyms
GET
/indexes/:index_uid/settings/synonyms
Get the list of synonyms of an index.
Path Variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
$ curl \
-X GET 'http://localhost:7700/indexes/movies/settings/synonyms'
client.index('movies').getSynonyms()
client.index('movies').get_synonyms()
$client->index('movies')->getSynonyms();
index.synonyms
client.Settings("movies").GetSynonyms()
let synonyms: HashMap<String, Vec<String>> = movies.get_synonyms().await.unwrap();
Response: 200 OK
{
"wolverine": ["xmen", "logan"],
"logan": ["wolverine", "xmen"],
"wow": ["world of warcraft"]
}
Update synonyms
POST
/indexes/:index_uid/settings/synonyms
Update the list of synonyms of an index.
Path Variables
Variable | Description |
---|---|
index_uid | The index UID |
Body
An object that contains all synonyms and their associated words.
More information about the body.
Example
$ curl \
-X POST 'http://localhost:7700/indexes/movies/settings/synonyms' \
--data '{
"wolverine": ["xmen", "logan"],
"logan": ["wolverine", "xmen"],
"wow": ["world of warcraft"]
}'
client.index('movies').updateSynonyms({
wolverine: ['xmen', 'logan'],
logan: ['wolverine', 'xmen'],
wow: ['world of warcraft']
})
client.index('movies').update_synonyms({
'wolverine': ['xmen', 'logan'],
'logan': ['wolverine', 'xmen'],
'wow': ['world of warcraft']
})
$client->index('movies')->updateSynonyms([
'wolverine': ['xmen', 'logan'],
'logan': ['wolverine', 'xmen'],
'wow': ['world of warcraft']
]);
index.update_synonyms({
wolverine: ['xmen', 'logan'],
logan: ['wolverine', 'xmen'],
wow: ['world of warcraft']
})
synonyms := map[string][]string{
"wolverine": []string{"xmen", "logan"},
"logan": []string{"wolverine", "xmen"},
"wow": []string{"world of warcraft"},
}
client.Settings("movies").UpdateSynonyms(synonyms)
let mut synonyms = std::collections::HashMap::new();
synonyms.insert(String::from("wolverine"), vec![String::from("xmen"), String::from("logan")]);
synonyms.insert(String::from("logan"), vec![String::from("xmen"), String::from("wolverine")]);
synonyms.insert(String::from("wow"), vec![String::from("world of warcraft")]);
let progress: Progress = movies.set_synonyms(&synonyms).await.unwrap();
Response: 202 Accepted
{
"updateId": 1
}
This updateId
allows you to track the current update.
Reset synonyms
DELETE
/indexes/:index_uid/settings/synonyms
Reset the list of synonyms of an index to its default value.
Default value
Empty object : {}
Path Variables
Variable | Description |
---|---|
index_uid | The index UID |
Example
$ curl \
-X DELETE 'http://localhost:7700/indexes/movies/settings/synonyms'
client.index('movies').resetSynonyms()
client.index('movies').reset_synonyms()
$client->index('movies')->resetSynonyms();
index.reset_synonyms
client.Settings("movies").ResetSynonyms()
movies.reset_synonyms().await.unwrap();
Response: 202 Accepted
{
"updateId": 1
}
This updateId
allows you to track the current update.