Database Reference
In-Depth Information
Fuzzy match - fuzzystrmatch
This extension provides a set of functions for determining the distance and similarity
between strings. Search engines such as Google search for similar words; through the ex-
tension fuzzystrmatch you are able to use this feature in your queries.
In the following example, you will add some names and use the function called differ-
ence to discover their similarity. This function returns a value from 0 to 4, where 0 (zero)
is the exact match and 4 (four) is the distant correspondence:
$ heroku pg:psql --app your-app-name
CREATE EXTENSION fuzzystrmatch;
CREATE TABLE doctors (name text);
INSERT INTO doctors (name) VALUES ('Patrick');
INSERT INTO doctors (name) VALUES ('Padrig');
SELECT difference(
(SELECT name FROM doctors WHERE name = 'Patrick'),
(SELECT name FROM doctors WHERE name = 'Padrig')
);
difference
------------
4
There are other functions such as soundex , levenshtein , metaphone , and dmeta-
phone . You can find more information about them on the extension documentation at ht-
tp://www.postgresql.org/docs/current/static/fuzzystrmatch.html .
Search WWH ::




Custom Search