suo
Concepts

Typo tolerance rules

When suo corrects a typo, when it does not, and why typo correction is disabled for CJK.

Typo tolerance lets higlights find highlights. It is on by default, tunable per searchable tier, and applied only when it is likely to help.

When correction kicks in

Typo expansion is lazy: suo runs the exact and prefix match first, and only reaches for typo correction when that first pass returns fewer results than needed.

Query lengthTypo distance allowed
Under 4 charactersNone
4–7 charactersDistance 1 (one insertion, deletion, substitution or transposition)
8 or more charactersDistance 1, then distance 2 by a second hop if distance 1 is not enough

At most 8 corrected variants of a token are tried, chosen by how common each candidate term is in the index, so a rare misspelling does not get lost among rarer near-matches.

What is never corrected

  • The prefix token — the last, still-being-typed word — is never typo-corrected below 5 characters, so sear does not get treated as a typo of some unrelated 4-letter word while you are mid-word on "search".
  • CJK tokens are never typo-corrected. Character-level edit distance does not mean the same thing in Chinese or Japanese that it means in an alphabetic script, and bigram matching already gives CJK queries a wide recall net — see CJK.

Turning it off

Set typoTolerance: false in an index's query-time settings, or pass it per-request to override for one query. Some indexes — a table of exact product SKUs, for example — are more useful with typo tolerance off entirely.

Showing the correction

When a query is corrected, the response's correctedQuery is set, and the widget shows "Showing results for highlights · search for higlights instead" above the results, so the correction is never silent. If the corrected query also returns nothing, the ordinary zero-result "did you mean" state takes over instead.

After typos: synonyms and dropped words

If typo-corrected candidates are still not enough, suo tries synonym expansion next, then — only on an otherwise empty result — drops trailing words from the query one at a time. See Synonyms and pins.

On this page