Configuring typo tolerance
On this page
Typo tolerance is on by default. You can change the typo tolerance behavior in the Typo-Tolerance section of Algolia’s dashboard or with the typoTolerance
parameter:
true
: turns typo tolerance on (the default, suggested value).false
: turns typo tolerance off.min
: only keeps results with the lowest number of typos. This means that if you have one or more records that match, you’ll only receive those records, but if you have no records that match, you’ll receive records with typo counts of 1 (or 2 if there are none with 1). When using a sort-by attribute, set typo tolerance tomin
to reduce irrelevant search results.strict
: likemin
but keeps the two lowest number of typos. This is useful when you want to ensure more results.
When typoTolerance
is min
or strict
, the Typo criterion is forced to be first in the ranking formula.
When typo tolerance is true
, min
, or strict
, Algolia enables splitting and concatenation.
Configure word size threshold for typos
Algolia can handle up to two typos in a word. It can also handle three typos if the first letter is misspelled.
Depending on the length of the word, each word in a query can have up to two typos:
- One typo is allowed for words with 4 or more characters. Change this 4-character default with the
minWordSizefor1Typo
parameter or the Min chars to accept 1 typo setting in the dashboard. - Two typos are allowed for words with 8 or more characters. Change this 8-character default with the
minWordSizefor2Typos
parameter or the Min chars to accept 2 typos setting in the dashboard.
Reducing these limits can be beneficial, depending on your specific needs. Experiment with different settings to see what works best for your users.
Three typos
Algolia handles up to three typos if the first typo is on the first character and
the word is long enough to meet the minWordSizefor2Typos
setting.
Benefits of reducing word size threshold
- A more forgiving search experience due to increased tolerance for typos. This can be helpful for mobile apps where typing errors are common.
- Improved results for short words. If your records contain many short words, reducing the threshold can help users find these words even if they make a typo.
Drawbacks of reducing word size threshold
- Increased chance of irrelevant results. Allowing typos on short words can lead to irrelevant or overly numerous results.
Typos on the first letter
When a typo occurs on the first character of a word, Algolia may treat it differently from other typos:
- The match is still considered a single typo for typo tolerance settings:
minWordSizefor1Typos
andminWordSizefor2Typos
. - It’s counted as two typos for ranking purposes and may appear lower in the results than matches with a single typo elsewhere.
For example, a user types “uffice” instead of “office”. That’s just one typo but it may rank lower than another result with a typo in a different position.
Treat singular and plural words the same
Singular and plural word forms aren’t the same by default: foot ≠ feet
.
Change this default behavior, so that foot = feet
, by setting the ignorePlurals
parameter to true
, or in the Language configuration page in the dashboard.
Typo tolerance and numbers
Typo tolerance is active on numbers by default. This, for example, allows users to make one or two wrong entries in a telephone number. For attributes such as postal codes, it makes sense to turn off typo tolerance for numbers since any typo will return many false positive results.
Change this default behavior by setting the allowTyposOnNumericTokens
parameter to false
or in the Typo-Tolerance section in the dashboard.
Turn off typo tolerance for specific attributes
You can turn off typo tolerance for specific searchable attributes. This is useful, for example, to turn off typo tolerance on product SKU codes.
Specify the attributes with the disableTypoToleranceOnAttributes
parameter or in the Typo-Tolerance section in the dashboard.
Turn off typo tolerance for certain words
You can specify a list of words that require exact matches. This is useful, for example, for acronyms like “mysql,” “php,” or “mamp.”
Use the disableTypoToleranceOnWords
parameter to specify the list of words or define them in the Typo-tolerance section of the Algolia dashboard.
Splitting and concatenation are also turned off for the specified words.