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.

Learn more about synonyms

Get synonyms

GET

  1. /indexes/:index_uid/settings/synonyms

Get the list of synonyms of an index.

Path Variables

VariableDescription
index_uidThe index UID

Example

  1. $ curl \
  2. -X GET 'http://localhost:7700/indexes/movies/settings/synonyms'
  1. client.index('movies').getSynonyms()
  1. client.index('movies').get_synonyms()
  1. $client->index('movies')->getSynonyms();
  1. index.synonyms
  1. client.Settings("movies").GetSynonyms()
  1. let synonyms: HashMap<String, Vec<String>> = movies.get_synonyms().await.unwrap();

Response: 200 OK

  1. {
  2. "wolverine": ["xmen", "logan"],
  3. "logan": ["wolverine", "xmen"],
  4. "wow": ["world of warcraft"]
  5. }

Update synonyms

POST

  1. /indexes/:index_uid/settings/synonyms

Update the list of synonyms of an index.

Path Variables

VariableDescription
index_uidThe index UID

Body

An object that contains all synonyms and their associated words.

More information about the body.

Example

  1. $ curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings/synonyms' \
  3. --data '{
  4. "wolverine": ["xmen", "logan"],
  5. "logan": ["wolverine", "xmen"],
  6. "wow": ["world of warcraft"]
  7. }'
  1. client.index('movies').updateSynonyms({
  2. wolverine: ['xmen', 'logan'],
  3. logan: ['wolverine', 'xmen'],
  4. wow: ['world of warcraft']
  5. })
  1. client.index('movies').update_synonyms({
  2. 'wolverine': ['xmen', 'logan'],
  3. 'logan': ['wolverine', 'xmen'],
  4. 'wow': ['world of warcraft']
  5. })
  1. $client->index('movies')->updateSynonyms([
  2. 'wolverine': ['xmen', 'logan'],
  3. 'logan': ['wolverine', 'xmen'],
  4. 'wow': ['world of warcraft']
  5. ]);
  1. index.update_synonyms({
  2. wolverine: ['xmen', 'logan'],
  3. logan: ['wolverine', 'xmen'],
  4. wow: ['world of warcraft']
  5. })
  1. synonyms := map[string][]string{
  2. "wolverine": []string{"xmen", "logan"},
  3. "logan": []string{"wolverine", "xmen"},
  4. "wow": []string{"world of warcraft"},
  5. }
  6. client.Settings("movies").UpdateSynonyms(synonyms)
  1. let mut synonyms = std::collections::HashMap::new();
  2. synonyms.insert(String::from("wolverine"), vec![String::from("xmen"), String::from("logan")]);
  3. synonyms.insert(String::from("logan"), vec![String::from("xmen"), String::from("wolverine")]);
  4. synonyms.insert(String::from("wow"), vec![String::from("world of warcraft")]);
  5. let progress: Progress = movies.set_synonyms(&synonyms).await.unwrap();

Response: 202 Accepted

  1. {
  2. "updateId": 1
  3. }

This updateId allows you to track the current update.

Reset synonyms

DELETE

  1. /indexes/:index_uid/settings/synonyms

Reset the list of synonyms of an index to its default value.

Default value

Empty object : {}

Path Variables

VariableDescription
index_uidThe index UID

Example

  1. $ curl \
  2. -X DELETE 'http://localhost:7700/indexes/movies/settings/synonyms'
  1. client.index('movies').resetSynonyms()
  1. client.index('movies').reset_synonyms()
  1. $client->index('movies')->resetSynonyms();
  1. index.reset_synonyms
  1. client.Settings("movies").ResetSynonyms()
  1. movies.reset_synonyms().await.unwrap();

Response: 202 Accepted

  1. {
  2. "updateId": 1
  3. }

This updateId allows you to track the current update.