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 language(s) using queryLanguages, we consider these variations as 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, which we maintain in around 50 languages. You can view the complete list of supported languages in the ignorePlurals usage notes. While we regularly update these dictionaries, you can also customize which words we consider as declined forms using your Algolia dashboard.

Each 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 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. Refer to our guide on how to set an index’s query language to learn more.

Inspecting plurals and other declined forms

You may be curious to see what declined forms we’ve already included in a particular language. Using the Algolia dashboard, you can search for words to see if we include them in a group of declined versions and what the alternatives are.

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 inspect on the screen’s top right. Plurals & Other Declensions dictionaries are language-specific.
  4. Select the Plurals & Other Declensions dictionary.
  5. Search for a specific word by typing it into the input bar. If we provide alternatives for it out of the box, or if you created a set of alternatives for it, these appear below.

Searching for words or their declined forms is exact. We only find a word and its alternatives once you’ve fully and correctly entered it—we don’t use prefix search 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 vocabularly. For example, a brand-specific word like “iPhone” isn’t included in our 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. Plurals & Other Declensions dictionaries are language-specific.
  4. Select the Plurals & Other Declensions dictionary.
  5. Search for a specific word by typing it into the input bar. If we provide alternatives for it out of the box, or if you’ve created a set of alternatives for it, these appear below.
  6. If no entry exists, the Add (+) button to the right of the search input field 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.

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. Plurals & Other Declensions dictionaries are language-specific.
  4. Select the Plurals & Other Declensions dictionary.
  5. Search for a specific word by typing it into the input field. If we provide alternatives for it out of the box or if you created a set of alternatives for it, these appear below.
  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 alternative(s) by typing it in the input or remove alternative(s) 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, we only use the custom group to determine equivalences.

While you can delete custom groups of alternatives, you can’t delete out-of-the-box groups. To disable 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?