Alternative Correction Synonyms
Alternative corrections are just like one-way synonyms, except they generate matches with typos to create a different ranking. Use alternative corrections when you want records with an exact query match to rank higher than a synonym match.
For example, consider the pants ⇔ trousers
synonym. Although you want searches for “pants” or “trousers” to return all records with either “pants” or “trousers”, you might want a search for “trousers” to rank results with “dress trousers” higher than results with “casual pants”. This is helpful when you need to use alternative corrections: trousers → pants, typo 1
, which means that the query “trousers” ranks records including “trousers” higher than records including “pants”.
When creating synonyms, including one-way synonyms, records with the original term and records with the synonym will be ranked evenly, all other things being equal.
There are two types of alternative corrections based on the type
parameter:
altCorrection1
will return matches with one typoaltCorrection2
will return matches with two typos.
Alternative corrections don’t support correcting typos in multiple words.
The following JSON defines an alternative correction with one typo:
1
2
3
4
5
6
7
8
{
"objectID": "a-unique-identifier",
"type": "altCorrection1",
"word": "tablet",
"corrections":[
"ipad"
]
}
This synonym definition ranks records with “tablet” before “ipad” since records with “ipad” are considered to have one typo.
Changing the type to altCorrection2
defines an alternative correction with two typos.
1
2
3
4
5
6
7
8
9
{
"objectID": "a-unique-identifier",
"type": "altCorrection2",
"word": "tablet",
"corrections":[
"ipad"
]
}