- Missing letters: “hllo” → “hello”
- Extra letters: “heello” → “hello”
- Swapped letters: “hlelo” → “hello”
- Substituted letters: “heilo” → “hello”
What’s typo tolerance?
Typo tolerance lets users make mistakes while typing but still find the records they’re looking for. This is done by matching words that are close in spelling. Tolerating typos is fundamental to modern search experiences for two reasons:- Typos are inevitable on mobile devices.
- Because products and services are growing in both complexity and global reach, not everyone knows the right way to spell a word.
By default, Algolia matches query terms at the beginning of words in your records (prefix matching). For alternatives, see Match queries in the middle or end of words.
How typos are calculated
Algolia’s algorithm for dealing with typos is based on the difference in spelling between a query word and its exact match in the index: the distance.Calculating distance
Distance is the count of operations (additions, deletions, substitutions, or transpositions) needed to change one word into another. For example, the query “strm” might mean “storm” or “strum” (distance=1), “star” or “warm” (distance=2). The following examples illustrate the calculated distances between various search queries and the target word “Michael”.- michael = 0. Algolia isn’t case-sensitive (“michael” = “Michael”)
- mickael = 1 (substitution: h → k)
- micael = 1 (deletion: h)
- mickhael = 1 (addition: k)
- micheal = 1 (transposition: a ⇄ e)
- mickaell = 2 (substitution: h → k, addition: l)
- Tichael = 2 (substitution: m → T, first letter)
- Tickael = 3 (substitution: m → T, first letter, substitution h → k).
- Logogram-based languages, such as Chinese and Japanese, use pictures to represent words (or partial words). Typo tolerance only applies to phonemic languages (such as English, French, and Russian), where characters represent sounds to form words.
- Punctuation and special characters
- Splits and concatenations (insertion or removal of spaces between two words)
- Any user query between quotes (if you’ve enabled
advancedSyntax
).