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.
Install
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:
Confirm it is there:
To build it yourself, follow the build instructions in the
repository.
What it adds
Example
Two spellings of the same name produce the same Soundex code, and difference
scores the match out of 4:
Edit distance counts the changes instead:
Metaphone handles the sounds that spelling hides, such as the Th in Thompson:
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”.
See also