Configuring Typo Tolerance
On this page
Enable, Disable, or More strict Typo Tolerance
Typo tolerance is enabled by default. For most clients, this is the best course of action. Other options include disabling it completely, or making it more strict. You control these options with the typoTolerance setting.
Typo tolerance is enabled by default. For most clients, this is the best setting.
Other options include disabling typo tolerance completely, or limiting its effects.
You have 4 possibilities.
true: Activate typo-tolerance (default, suggested value).
false: Disable typo-tolerance.
min: Only keep results with the lowest number of typos. This means that if you have 1 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).
strict: Similar to 3, but keep the 2 lowest number of typos. This is useful when you want to ensure more results.
- When typoTolerance is set to strict, we force the Typo criterion to be first in the ranking formula.
- When using a sort-by attribute, we recommend setting typo-tolerance to min to reduce the number of potentially irrelevant search results.
Configuring Word Length for Typos
Word length for 1 typo
Typos are only tolerated when the query reaches a certain character length. The default is 4 - this means that the engine waits for the user to enter 4 characters before applying typo tolerance.
You can override this default with the minWordSizefor1Typo setting. As soon as a word contains at least minWordSizefor1Typo characters, the engine will allow one typo in matches.
Word length for 2 typos
An additional setting is to tell the engine when to start considering 2 typos. As soon as the query contains at least minWordSizefor2Typos characters, the engine will allow up to two typos in matches. Default is 8 characters.
Typos are counted per-word. In the case of multi-word queries, it’s possible for each word of the query up to 2 typos, according to minWordSizefor1Typo and minWordSizefor2Typo.
Treating Singulars and Plurals as Equivalent
If activated, this feature is designed to match words written in the plural form even if the query is in the singular form, and vice-versa. It’s built on a dictionary of singular and plural forms of words in over eighty languages. It works for simple plurals like
hand ⇄ hands as well as more complex ones like
feet ⇄ foot.
This parameter accepts a boolean or array value. We recommend passing an array of the specific ISO codes of languages you target. For example:
Granular Targeting of Typo-Tolerance
Typos Tolerance and Numerics
By default, numeric attributes are included in the typo tolerance logic. This allows for one or two wrong numbers in a telephone number. It makes sense to disable it in specific situations such as postal codes - if typos are enabled, any postal code query will return a lot of false positive results.
Disabling typo tolerance on a specific attribute
You can enable typo tolerance globally and disable it for specific attributes. This is useful, for example, with products that might require SKU search without typo-tolerance.
Disabling typo tolerance for certain words
You can define a list of words for which typo-tolerance should be disabled. This is useful, for example, with acronyms like “mysql,” “php”, or “mamp”.
Specifying Your Own Alternative Corrections
When the default typo-tolerance is not enough, additional alternative corrections can be specified. Alternative corrections defined, the query “foot” will match with records containing “feet”, and vice versa, but this will be considered as 1 typo. Without these corrections, “foot” and feet” would have been considered synonymous, with zero typos, if you had set
ignorePlurals to true (where feet ⇄ foot).