Fuzzy search finds strings that approximately match a query instead of requiring every character to be exact. It is the reason a search for samsng can still find “Samsung” and szechun noodles can still find “Szechuan noodles.”
Ever seen Google correcting you like this?

That is fuzzy matching at work. The search system considers terms that are close to the query, then ranks the most plausible results. The user gets a useful result without having to stop, spot the typo, and search again.
What is fuzzy search?
Fuzzy search is a search technique that accepts close variations of a word. Most implementations use an edit-distance algorithm to measure how many small character changes separate the query from a term in the index.
For example, coat and cost are one substitution apart. coat and boat are also one substitution apart. A system configured to allow one edit can consider both strings as candidates, then use exact matches and its other ranking signals to decide which results belong at the top.
Fuzzy search is often described as typo tolerance when it is built into a search experience. The two ideas overlap, but fuzzy matching is the mechanism while typo tolerance is the user-facing behavior. A good typo-tolerant search also considers word length, exact matches, field importance, and how many useful results already exist before expanding the query.
Fuzzy search should not silently replace the query in every situation. Obscure names, short words, product codes, and specialist terms can look like mistakes even when they are correct. This is why many search engines support exact phrase syntax, often by wrapping a query in quotes.

How fuzzy search works
A typical fuzzy search follows a few steps:
- Normalize and tokenize the query using the same rules as the indexed text.
- Look for exact terms first.
- If the exact search does not produce enough useful matches, generate or find nearby candidate terms.
- Measure the edit distance between the query term and each candidate.
- Combine that distance with the engine’s other ranking signals.
This order matters. A document that contains the query exactly should normally outrank one that matches only after a typo correction. Fuzziness widens the candidate set; it does not replace relevance ranking.
Candidate generation is also where much of the performance cost lives. A long dictionary can contain many terms within one or two edits of a query. Search systems limit that work with rules such as minimum word length, a maximum edit distance, an exact prefix, or a cap on the number of candidate terms.
Measuring string similarity with edit distance
When two strings don’t match each other exactly, we need a metric to indicate how similar they are to each other.
Such a metric is called an edit distance, and there are several algorithms for measuring the edit distance between two strings.
Levenshtein distance
Arguably the most popular string similarity metric, it computes the number of deletions, insertions and substitutions needed to transform one string into another.
insertion: bat → boat
deletion: coat → cot
substitution: coat → cost
If there are multiple ways to transform a string to another, the Levenshtein distance is the smallest number of operations required to do the transformation.
Damerau-Levenshtein distance
Damerau-Levenshtein is an extension to the Levenshtein distance metric. In addition to insertion, deletion and substitution, it also treats transposition as a primitive operation.
Transposition is the swapping of two adjacent letters in a string.
transposition: caot → coat
Transposition is common when someone types quickly, so Damerau-Levenshtein often maps more closely to real spelling errors than plain Levenshtein distance.
Longest common subsequence (LCS)
LCS is a similarity metric that considers only insertion and deletion. Given two strings, LCS finds the longest subsequence between them. Such a subsequence is not required to occupy consecutive positions within the original sequence.
In the following example,
ABCD → ACBAD
The two strings share two common subsequences of length 3: ABD and ACD.
LCS is used in the Linux diff utility and in revision control systems such as Git for displaying the changes between
two versions of a file.
LCS is useful for understanding similarity, but edit-distance algorithms are the more common foundation for typo-tolerant word search because their operations map neatly to typing mistakes.
Fuzzy search examples
The right tolerance depends on the query. These examples illustrate why one global rule is rarely enough:
| Query | Intended term | Edit | Likely treatment |
|---|---|---|---|
iphnoe | iphone | One transposition | Allow |
samsng | samsung | One insertion | Allow |
coat | cost | One substitution | Prefer exact coat results first |
cat | car | One substitution in a short word | Use caution |
XR-500 | XR-500 | None | Usually require exact matching |
A one-character change in a three-letter word can alter a large part of its meaning. The same change in a ten-letter word is more likely to be a typo. Many implementations therefore allow more edits only after a word reaches a minimum length.
When to use fuzzy search
Fuzzy search is especially helpful when users type from memory or enter unfamiliar text:
- Product and site search, where a missed character should not hide the right item
- Names and addresses, which have legitimate spelling variations
- Mobile search, where adjacent-key errors and transpositions are common
- Large content collections, where users may not know the exact terminology
- Search-as-you-type interfaces, as long as partial-prefix matching and typo matching are ranked carefully
It needs tighter controls for very short queries, identifiers, SKUs, legal codes, and fields where one character changes the meaning. You can disable fuzzy matching on those fields, require an exact prefix, or try exact matching before using a fuzzy fallback.
Also watch for a query that already has strong results. Expanding a popular exact query can introduce loosely related matches and weaken relevance for no benefit. A useful policy is to look for typo-corrected candidates only when the exact query returns too few results.
How to implement fuzzy search
The implementation depends on the size of the dataset and where the search runs.
For a small list already loaded in a browser, Fuse.js offers fuzzy search in JavaScript without a server-side index. For data cleaning or entity matching, this guide compares fuzzy string matching approaches in Python.
For a larger application, use a search index rather than comparing the query with every record. A search engine can maintain term dictionaries and purpose-built data structures for finding close candidates efficiently. Your integration should still decide:
- The maximum number of edits allowed by word length
- Which fields allow typo tolerance
- Whether part numbers and numeric tokens must match exactly
- How exact matches are prioritized
- When fuzzy candidates are attempted
- How much candidate expansion is acceptable for latency
Typesense uses Damerau-Levenshtein distance for typo tolerance and exposes search-time controls such as num_typos, min_len_1typo, min_len_2typo, and typo_tokens_threshold. The Typesense typo-tolerance parameters document the available controls, while the ranking and relevance guide explains how edit distance fits into result ordering.
Elasticsearch takes a different approach through the fuzziness setting on match queries. The Elasticsearch typo-tolerance guide covers that query behavior and its tradeoffs.
Tuning fuzzy search without losing relevance
Start conservatively. Allow one typo for moderately long words, keep short tokens exact, and rank exact matches above fuzzy ones. Then test against real queries rather than a handpicked list of misspellings.
Useful measurements include zero-result rate, reformulation rate, click-through rate after a corrected query, and latency at broad candidate sets. Review false positives as closely as missed matches. If coat consistently leads to cost when users really meant coat, the search may be tolerant but it is not helpful.
The goal is not to make every string match something. It is to recover the user’s likely intent while keeping precise queries precise. When fuzzy search follows that rule, typos become a small detail instead of a dead end.