Search code examples
mysqlalgorithmlevenshtein-distance

Damerau–Levenshtein distance algorithm in MySQL as a function


Does anyone know of a MySQL implementation of the Damerau–Levenshtein distance algorithm as a stored procedure/function that takes a single specified string as a parameter and looks for fuzzy matches of the string in a particular field within a particular table?

I have found various procedure/function code examples that compares two specified strings and works out the distance, but firstly this is only the Levenshtein distance algorithm, and not the Damerau–Levenshtein one, and secondly, I'm not looking to compare two strings but find fuzzy matches in a field of my choosing that are similar to my specified string.

I'm basically trying to put together a fuzzy keyword searcher in MySQL.


Solution

  • In MySQL Levenshtein and Damerau-Levenshtein UDF’s you have several implementations of this algorithm.