Typo tolerance calculations

    Typo tolerance helps users find relevant results even when their search queries contain spelling mistakes or typos, for example, typing phnoe instead of phone. You can configure the typo tolerance feature for each index.

    Meilisearch uses a prefix Levenshtein algorithm to determine if a word in a document could be a possible match for a query term.

    The number of typos referenced above is roughly equivalent to Levenshtein distance. The Levenshtein distance between two words M and P can be thought of as "the minimum cost of transforming M into P" by performing the following elementary operations on M:

    By default, Meilisearch uses the following rules for matching documents. Note that these rules are by word and not for the whole query string.

    This means that saturday which is 7 characters long, uses the second rule and matches every document containing one typo. For example:

    Impact of typo tolerance on the typo ranking rule

    The typo ranking rule sorts search results by increasing number of typos on matched query words. Documents with 0 typos will rank highest, followed by those with 1 and then 2 typos.

    The presence or absence of the typo ranking rule has no impact on the typo tolerance setting. However, disabling the typo tolerance setting effectively also disables the typo ranking rule. This is because all returned documents will contain 0 typos.

    To summarize: