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

Alternative correction synonyms

Alternative corrections function similarly to one-way synonyms but with an important distinction: they handle typos in search queries differently, which affects search results ranking. This is helpful when you want search results that exactly match a query to appear higher in the list than those matching a synonym. Take the synonym pair pants <=> trousers as an example. If someone searches for “trousers”, you might prefer that “dress trousers” appears higher in the search results than “casual pants”.

Alternative corrections can only find matches with one typo or two typos (altCorrection1 or altCorrection2).

How to define alternative corrections

To define an alternative correction that accounts for one typo, such as “pamts” or “trouser”, use the following JSON:

1
2
3
4
5
6
{
  "objectID": "a-unique-identifier",
  "type": "altCorrection1",
  "word": "trousers",
  "corrections": ["pants"]
}

For an alternative correction that accounts for two typos, such as “psant” or “trosuers”, the format is similar:

1
2
3
4
5
6
{
  "objectID": "a-unique-identifier",
  "type": "altCorrection2",
  "word": "trousers",
  "corrections": ["pants"]
}
Did you find this page helpful?