Skip to content

ML Models & Algorithms

Distance-based matching

In shortFuzzy string matching that scores how many character edits separate two strings, so near matches with typos or small spelling changes can be found.

Updated 24 Oct 2026· 2 min read

Distance-based matching is a family of fuzzy matching methods that measure how far apart two strings are by counting the edits needed to turn one into the other. The fewer edits, the closer the match. It is the go-to approach when the same thing is written in slightly different ways, such as typos, plurals or small URL changes.

How it works

The core idea is edit distance: the minimum number of operations needed to convert one string into another. The main variants differ in which operations they allow:

  • Levenshtein distance counts insertions, deletions and substitutions.
  • Damerau-Levenshtein also counts swapping two neighbouring letters as one edit.
  • Jaro and Jaro-Winkler score shared characters and transpositions; Jaro-Winkler rewards strings that start the same way, which is why it is popular for names.

Most SEO scripts use a normalised similarity score from 0 to 100 instead of the raw distance. Libraries such as RapidFuzz and TheFuzz compute these scores quickly and offer variants that ignore word order or compare the best-matching part of a longer string.

How it’s used in SEO and marketing

  • 404 and redirect mapping. Match broken or old URLs to the closest live URL during migrations.
  • Keyword variants. Group misspellings and near-duplicates in a keyword list.
  • Metadata checks. Compare your titles with competitors’ to find near-identical phrasing.
  • Data cleaning. Deduplicate product names, author names or company names across exports.

Example

MLforSEO’s fuzzy matching guide uses HARD, HAND and HARDER. By raw Levenshtein distance, HARD and HAND are closer (one substitution) than HARD and HARDER (two insertions). But the normalised ratio in RapidFuzz and FuzzyWuzzy is built on insertions and deletions only, and it rates HARD/HARDER at 80 and HARD/HAND at 75. Neither score understands meaning; they simply measure spelling differently. Always check which score your library returns before setting a threshold.

Limitations and things to watch

  • It ignores meaning: “cheap flights” and “budget airfare” score as very different. Use embeddings or Sentence-BERT when meaning matters.
  • Short strings swing wildly, since one edit is a large share of a short word.
  • Comparing every string with every other string gets slow on large lists, so use vectorised functions or narrow the candidates first.
  • Thresholds need tuning on a hand-checked sample.

Learn it on MLforSEO

Where Distance-based matching shows up on MLforSEO

Sources and further reading

Other terms from ML Models & Algorithms

See all 55 ML Models & Algorithms terms →