🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
Guides / Managing results / Optimize search results / Handling natural languages

Customize plurals and other declensions

Depending on the language, words can have multiple declined forms based on the number (singular or plural), gender (masculine, feminine, neuter), and the case (nominative, accusative, genitive, etc.). When you enable ignorePlurals and set the appropriate languages using queryLanguages, these variations are considered to be equivalent during search.

For example, with ignorePlurals enabled and queryLanguages set to English, the queries “shirt” and “shirts” return the same results.

With ignorePlurals enabled and queryLanguages set to German, the queries “hemd”, “hemde”, “hemds”, “hemden”, and “hemdes” return the same results. Some groups of declined forms also include common diminutives. For example, the Dutch declensions dictionary includes “hemd”, “hemden”, “hemdje”, and “hemdjes” in its group of alternatives.

The ignorePlurals parameter relies on language-specific dictionaries. You can customize which words to consider as declined forms using the Algolia dashboard.

Each Algolia application uses one declension dictionary per language. This means that you can’t create different customizations for the same language for different indices in one Algolia application. If you want to create certain equivalencies only when searching certain indices, consider using synonyms instead.

You should use ignorePlurals and other language-specific features in conjunction with the queryLanguages setting. For more information, see How to set an index query language to learn more.

Inspecting plurals and other declined forms

You can use the dashboard to search for declined forms and their alternatives for a particular language:

  1. Select the Search product icon on your dashboard.
  2. Navigate to the Dictionaries page in the left sidebar menu of the dashboard.
  3. Select the language whose declined forms you want to inspect on the screen’s top right. Plural and declension dictionaries are language-specific.
  4. Select the dictionary.
  5. Search for a specific word by typing it into the input box. If there are Algolia alternatives or if you created custom alternatives, these appear below the input box.

Searching for words or their declined forms is exact. A word and its alternatives only appear once you’ve fully and correctly entered it: the input box doesn’t use prefix searching or typo tolerance.

Adding a missing group of alternatives

You may search for a word and find that it doesn’t have any alternatives associated with it. This can happen when your use case includes English vocabulary in the context of another language or if you have use-case specific vocabulary.

For example, a brand-specific word like “iPhone” isn’t included in Algolia’s dictionary, but you may want searches for “iPhone” and “iPhones” to return the same results. In this case, you can add a custom group of alternatives so that “iPhones” is recognized as the plural of “iPhone”.

Using the dashboard

  1. Select the Search product icon on your dashboard.
  2. Navigate to the Dictionaries page in the left sidebar menu of the dashboard.
  3. Search for and select the language whose declined forms you want to customize on the screen’s top right. Plural and declension dictionaries are language-specific.
  4. Select the dictionary.
  5. Search for a specific word by typing it into the input box. If there are Algolia alternatives or if you created custom alternatives, these appear below the input box.
  6. If no entry exists, the Add (+) button to the right of the input box becomes enabled. When you click it, an input appears below with the searched-for word.
  7. In the input field, enter each word that should be considered an alternative for the word and then click Save.
  8. Click Review and Save on the bottom of the screen to save this and any other changes.

Customizing a group of alternatives

You may find that a particular group of declined form doesn’t include an alternative you would expect or contains a word that shouldn’t be considered equivalent for your use case. In this case, you should customize the existing group of alternatives from the dashboard:

  1. Select the Search product icon on your dashboard.
  2. Navigate to the Dictionaries page in the left sidebar menu of the dashboard.
  3. Search for and select the language whose declined forms you want to customize on the screen’s top right. Plural and declension dictionaries are language-specific.
  4. Select the dictionary.
  5. Search for a specific word by typing it into the input field. If there are Algolia alternatives or if you created custom alternatives, these appear below the input box.
  6. If an entry exists, you can either add new words or remove existing words from the list of alternatives by selecting the Edit option to the right of the group.
  7. Add new alternatives by typing it in the input or remove alternatives by clicking the Delete (x) button next to it. Click Save.
  8. Click Review and Save on the bottom of the screen to save this and any other changes.

Editing an out-of-the-box group of alternatives results in the creation of a custom group. The out-of-the-box group of alternatives also remains. When performing a search, if both an out-of-the-box group and custom group exist for a word, only the custom group is used to determine equivalences.

While you can delete custom groups of alternatives, you can’t delete out-of-the-box groups. To turn off all alternatives for a certain word, create a custom group where it is the only word. You can do this by editing a an out-of-the-box group and removing all alternatives.

Uploading and downloading customizations

You may have curated your own list of alternative forms for your use case. You can upload them in bulk in either CSV or JSON format using the Actions button with the gear icon.

CSV format

1
2
language, words, objectID, type
de, hund,hunde,hunds,hunden,hundes,hundchen,hundchens, 1, custom

The list of words must be a comma-separated list without any spaces.

JSON format

1
2
3
4
5
6
7
8
[
  {
    "language": "de",
    "words": ["hund", "hunde", "hunds", "hunden", "hundes", "hundchen", "hundchens"],
    "objectID": 1,
    "type": "custom"
  }
]

Using the Actions button, you can also download all custom alternatives from a dictionary, either in CSV or JSON format. You may choose to do this regularly to keep track of alternatives you added at a particular time.

Did you find this page helpful?