Skip to content

LearnRetrieve

Typo tolerance

Fuzzy matching · Edit-distance search

Matching query words to indexed words that differ by a small number of character edits, so “recovry” still finds “recovery”.

Related techniqueGlossary entry

On this page

Typo tolerance lets a query word match an indexed word that is a few character edits away. The usual measure is edit distance: the number of single-character insertions, deletions, substitutions or (Damerau’s addition) transpositions between two words. “ernings” is one insertion from “earnings”; “magrin” is one transposition from “margin”. Engines built for search-as-you-type usually scale the allowance with word length. Meilisearch’s defaults, for example, allow one typo from five characters and two from nine, and none in shorter words, where one edit turns “cat” into “car”.

It is not the same as stemming. Stemming maps grammatical variants to one form, so “forecasting” matches “forecasts”. It does nothing for misspellings: in Postgres full-text search, “ernings” matches nothing.

The gotcha: identifiers

Edit-distance matching assumes nearby spellings mean the same thing. For codes and names they don’t: tail numbers N750MC and N705MC are one transposition apart and name different aircraft, and a person named “Lee” is not “Leo”. Good implementations disable typo tolerance for numbers, short tokens and fields marked as identifiers. Character n-grams are another approach: index three-letter fragments and match words that share most of them.

DocSlurp does not do edit-distance matching. A typoTolerance setting exists in project search settings, but retrieval does not use it. Misspelled queries still often work through the vector branch, because subword tokenization often gives “ernings” and “earnings” similar embeddings, and optional query rewriting can fix spelling before search.

In DocSlurp

Related technique

DocSlurp has no edit-distance matching. Project search settings store a typoTolerance flag (core/server/src/services/search-controls.ts), but retrieval does not read it. Misspellings reach keyword search unchanged; the vector branch and optional query rewriting sometimes absorb them.

Sources

Jump to