The vsql_fuzzystrmatch extension adds Soundex, Metaphone, Double Metaphone, and Levenshtein edit distance to MySQL for name matching and deduplication.
vsql_fuzzystrmatch is a port of PostgreSQL’s fuzzystrmatch extension. It
answers two different questions about a pair of strings: do they sound alike,
and how many edits separate them. Use it for name matching, spelling
correction, and deduplicating records that were typed by hand.
vsql_fuzzystrmatch.veb is already in the server’s lib/veb/ directory if you
installed VillageSQL with the install script, the Docker image, or a release
tarball. Install it into the server with one statement:
MySQL has a SOUNDEX() of its own, and the built-in wins when you write the
name unqualified. The two disagree: SOUNDEX('Ashcraft') returns A2613,
while vsql_fuzzystrmatch.soundex('Ashcraft') returns A261. MySQL’s
version is documented as returning a string of any length, and the
extension’s follows the four-character Soundex definition. Qualify the call
with the extension name to get the one you mean. No other function here is
shadowed.
levenshtein_less_equal stops as soon as the true distance passes the limit
you give it, and then returns the limit plus 1, whatever the true distance
is. With a limit of 2 it returns 3 for a pair 3 apart and 3 for a pair 7
apart. Read the limit plus 1 as “further apart than you asked about”.