Settings

A set of words defined for an index. Synonyms are different words that have the same meaning, and thus are treated similarly. If either of the associated words is searched, the same results will be displayed.

synonyms=<Object>

  • <Object> (Object, defaults to {}) : { <String>: [<String>, <String>, ...], ... }

    An object that contains words with a list of their associated synonyms. Synonym strings are .

Learn more about synonyms

Example

Suppose you have an e-commerce dataset. For an index that contains information about tops, you decide to create synonyms for sweater and jumper since these two items are very similar.

  1. client.index('tops').updateSettings({
  2. synonyms: {
  3. sweater: ['jumper'],
  4. jumper: ['sweater']
  5. })
  1. client.index('movies').update_settings({
  2. 'synonyms': {
  3. sweater: ['jumper'],
  4. jumper: ['sweater']
  5. },
  6. })
  1. $client->index('tops')->updateSynonyms(['sweater' => ['jumper'], 'jumper' => ['sweater']]);
  1. index.update_settings({
  2. synonyms: {
  3. sweater: ['jumper'],
  4. jumper: ['sweater']
  5. }
  6. })
  1. synonyms := map[string][]string{
  2. "sweater": []string{"jumper"},
  3. "jumper": []string{"sweater"},
  4. }
  5. client.Settings("tops").UpdateSynonyms(synonyms)
  1. let mut synonyms = HashMap::new();
  2. synonyms.insert(String::from("sweater"), vec![String::from("jumper")]);
  3. synonyms.insert(String::from("jumper"), vec![String::from("sweater")]);
  4. let tops: Index = client.get_index("tops").await.unwrap();
  5. let progress: Progress = tops.set_synonyms(&synonyms).await.unwrap();

By doing so, when searching for black sweater, results for black jumper will also be returned.

Stop words

A set of words defined for an index. Because some words neither add semantic value nor context, you may want to ignore them from your search. Stop words are ignored during search.

stopWords=[<String>, <String>, ...]

  • [<String>, <String>, ...] (Array of strings, defaults to [])

    An array of strings that contains the stop words.

Example

To add the, a and an to the stop words list, send:

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings' \
  3. --data '{
  4. "stopWords": [
  5. "the",
  6. "a",
  7. "an"
  8. ]
  9. }'
  1. client.index('movies').updateSettings({
  2. stopWords: [
  3. 'the',
  4. 'a',
  5. 'an'
  6. ]
  7. })
  1. client.index('movies').update_settings({
  2. 'stopWords': [
  3. 'the',
  4. 'a',
  5. 'an'
  6. ],
  7. })
  1. $client->index('movies')->updateStopWords(['the', 'a', 'an']);
  1. index.update_settings({
  2. stopWords: [
  3. 'the',
  4. 'a',
  5. 'an'
  6. ]
  7. })
  1. stopWords := []string{"the", "a", "an"}
  2. client.Settings("movies").UpdateStopWords(stopWords)
  1. let progress: Progress = movies.set_stop_words(&["the", "a", "an"][..]).await.unwrap();

With the settings in the example above, the, a and an are now ignored by the sorting algorithm if they are present in search queries.

Suppose you would like to search the mask in a movie database. Since the is ignored during search, MeiliSearch will look for every movie containing mask and not the millions ones containing the. the is a less relevant term than mask and also a very frequent word in English. By adding the to the stop words list, MeiliSearch will ignore this word, and thus be faster to answer without losing in relevancy.

Faceted are the attributes used as facets. They must be added to the settings to be usable as .

attributesForFaceting=[<Attribute>, ...]

  • An array of strings that contains the attributes to use as facets.

WARNING

Only fields of data type string or array of strings can be used for faceting.
A null value will be ignored. In any other case, an error will be thrown.

Learn more about faceted attributes

Example

To be able to facet search on director and genres in a movie database, you would declare faceted attributes as follows:

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings' \
  3. --data '{
  4. "attributesForFaceting": [
  5. "director",
  6. "genres"
  7. ]
  8. }'
  1. client.index('movies')
  2. .updateAttributesForFaceting([
  3. 'director',
  4. 'genres'
  5. ])
  1. client.index('movies').update_attributes_for_faceting([
  2. 'director',
  3. 'genres',
  4. ])
  1. index.update_attributes_for_faceting([
  2. 'director',
  3. 'genres'
  4. ])
  1. response, error := client.Settings("movies").UpdateAttributesForFaceting([]string{
  2. "director",
  3. })
  1. let progress: Progress = movies.set_attributes_for_faceting(&["director", "genres"][..]).await.unwrap();

Ranking rules

Built-in ranking rules that ensure relevancy in search results. Ranking rules are applied in a default order which can be changed in the settings. You can add or remove rules and change their order of importance.

rankingRules=[<String>, <String>, ...]

  • [<String>, <String>, ...] (Array of strings, see default value below)

    An array of strings that contains the ranking rules sorted by order of importance (arranged from the most important rule to the least important rule).

Default value (the ranking rules in the default order):

  1. ["typo", "words", "proximity", "attribute", "wordsPosition", "exactness"]

You can add a custom ranking rule anywhere in the list of ranking rules. A custom ranking rule is composed of an attribute and an ascending or descending order. The attribute must have a numeric value in the documents.

Example

To add your ranking rules to the settings, send:

  1. -X POST 'http://localhost:7700/indexes/movies/settings' \
  2. --data '{
  3. "rankingRules": [
  4. "typo",
  5. "words",
  6. "proximity",
  7. "attribute",
  8. "wordsPosition",
  9. "exactness",
  10. "asc(release_date)",
  11. "desc(rank)"
  12. ]
  13. }'
  1. client.index('movies').updateSettings({
  2. rankingRules: [
  3. 'typo',
  4. 'words',
  5. 'proximity',
  6. 'attribute',
  7. 'wordsPosition',
  8. 'exactness',
  9. 'asc(release_date)',
  10. 'desc(rank)'
  11. ]
  12. })
  1. client.index('movies').update_settings({
  2. 'rankingRules': [
  3. 'typo',
  4. 'words',
  5. 'proximity',
  6. 'attribute',
  7. 'wordsPosition',
  8. 'exactness',
  9. 'asc(release_date)',
  10. 'desc(rank)'
  11. ]
  12. })
  1. $client->index('movies')->updateRankingRules([
  2. 'typo',
  3. 'words',
  4. 'proximity',
  5. 'attribute',
  6. 'wordsPosition',
  7. 'exactness',
  8. 'asc(release_date)',
  9. 'desc(rank)'
  10. ]);
  1. index.update_settings({
  2. rankingRules: [
  3. 'typo',
  4. 'words',
  5. 'proximity',
  6. 'attribute',
  7. 'wordsPosition',
  8. 'exactness',
  9. 'asc(release_date)',
  10. 'desc(rank)'
  11. ]
  12. })
  1. rankingRules := []string{
  2. "typo",
  3. "words",
  4. "proximity",
  5. "attribute",
  6. "wordsPosition",
  7. "exactness",
  8. "asc(release_date)",
  9. "desc(rank)",
  10. }
  11. client.Settings("movies").UpdateRankingRules(rankingRules)
  1. let ranking_rules = [
  2. "typo",
  3. "words",
  4. "proximity",
  5. "attribute",
  6. "wordsPosition",
  7. "exactness",
  8. "asc(release_date)",
  9. "desc(rank)",
  10. ];
  11. let progress: Progress = movies.set_ranking_rules(&ranking_rules[..]).await.unwrap();

With the settings in the example above, documents will be sorted by number of typos first. If too many documents have the same number of typos, the words rule will be applied. This operation will be repeated with the next rules until the requested number of documents has been reached (default: 20).

The value of a field whose attribute is set as a distinct attribute will always be unique in the returned documents.

distinctAttribute=<String>

  • <String> (String, defaults to null)

Example

Suppose you have an e-commerce dataset. For an index that contains information about jackets, you may have several identical items in different variations (color or size).

As shown below, you have 2 documents that contain information about the same jacket. One of the jackets is brown and the other one is black.

  1. [
  2. {
  3. "id": 1,
  4. "description": "Leather jacket",
  5. "brand": "Lee jeans",
  6. "color": "brown",
  7. "product_id": "123456"
  8. },
  9. {
  10. "id": 2,
  11. "description": "Leather jacket",
  12. "brand": "Lee jeans",
  13. "color": "black",
  14. "product_id": "123456"
  15. }
  16. ]

You may want to ignore the different colors of an item. To do so, you can set product_id as a distinctAttribute.

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/jackets/settings' \
  3. --data '{
  4. "distinctAttribute": "product_id"
  5. }
  1. client.index('movies').updateSettings({
  2. distinctAttribute: 'product_id'
  3. })
  1. client.index('movies').update_settings({
  1. $client->index('jackets')->updateDistinctAttribute('product_id');
  1. client.Settings("jackets").UpdateDistinctAttribute("movie_id")
  1. let jackets: Index = client.get_index("jackets").await.unwrap();
  2. let progress: Progress = jackets.set_distinct_attribute("product_id").await.unwrap();

With the settings in the example above, only one of the two documents will be returned if you search Lee leather jacket.

Searchable attributes

The content of the fields whose attributes are added to the searchable-attributes list are searched for matching query words.

searchableAttributes=[<String>, <String>, ...]

  • [<String>, <String>, ...] (Array of strings, defaults to all attributes found in the documents)

    An array of strings that contains searchable attributes ordered by importance (arranged from the most important attribute to the least important attribute).

Example

By adding the following settings, the fields title, description and genre will be searched.

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings' \
  3. --data '{
  4. "searchableAttributes": [
  5. "title",
  6. "description",
  7. "genre"
  8. ]
  9. }'
  1. client.index('movies').updateSettings({
  2. searchableAttributes: [
  3. 'title',
  4. 'description',
  5. 'genre'
  6. ]
  7. })
  1. client.index('movies').update_settings({
  2. 'searchableAttributes': [
  3. 'title',
  4. 'description',
  5. 'genre'
  6. ]
  7. })
  1. $client->index('movies')->updateSearchableAttributes([
  2. 'title',
  3. 'description',
  4. 'genre'
  5. ]);
  1. index.update_settings({
  2. searchableAttributes: [
  3. 'title',
  4. 'description',
  5. 'genre'
  6. ]
  7. })
  1. searchableAttributes := []string{
  2. "title",
  3. "description",
  4. "genre",
  5. }
  6. client.Settings("movies").UpdateSearchableAttributes(searchableAttributes)
  1. let searchable_attributes = [
  2. "title",
  3. "description",
  4. "genre"
  5. ];
  6. let progress: Progress = movies.set_searchable_attributes(&searchable_attributes[..]).await.unwrap();

The fields whose attributes are added to the are contained in each matching document.

Documents returned upon search contain only displayed fields.

displayedAttributes=[<String>, <String>, ...]

  • [<String>, <String>, ...] (Array of strings, defaults to all attributes found in the documents)

    An array of strings that contains attributes of an index to display.

Learn more about displayed attributes

Example

  1. curl \
  2. -X POST 'http://localhost:7700/indexes/movies/settings' \
  3. --data '{
  4. "displayedAttributes": [
  5. "title",
  6. "description",
  7. "genre",
  8. "release_date"
  9. ]
  10. }'
  1. client.index('movies').updateSettings({
  2. displayedAttributes: [
  3. 'title',
  4. 'description',
  5. 'genre',
  6. 'release_date',
  7. ]
  8. })
  1. client.index('movies').update_settings({
  2. 'displayedAttributes': [
  3. 'title',
  4. 'description',
  5. 'genre',
  6. 'release_date'
  7. ]
  8. })
  1. $client->index('movies')->updateDisplayedAttributes([
  2. 'title',
  3. 'description',
  4. 'genre',
  5. 'release_date'
  6. ]);
  1. index.update_settings({
  2. displayedAttributes: [
  3. 'title',
  4. 'description',
  5. 'genre',
  6. 'release_date'
  7. ]
  8. })
  1. displayedAttributes := []string{
  2. "title",
  3. "description",
  4. "genre",
  5. "release_date",
  6. }
  7. client.Settings("movies").UpdateDisplayedAttributes(displayedAttributes)
  1. let displayed_attributes = [
  2. "title",
  3. "description",
  4. "genre",
  5. "release_date"
  6. ];