Database Reference
In-Depth Information
Trigram - pg_trgm
The pg_trgm extension provides operators and functions to calculate the similarity of al-
phanumeric ASCII text with a trigram base match. A trigram is defined with a set of three
consecutive characters, made from a string; it is very effective for measuring the similarity
of words in natural languages.
The following example is very simple; you will use the similarity function to discover
the similarity between two strings. The return of this function can be between 0 and 1,
where 0 (zero) indicates that the strings are dissimilar and 1 (one) being similar.
$ heroku pg:psql --app your-app-name
CREATE EXTENSION pg_trgm;
SELECT similarity('PostgreSQL', 'Postgres');
similarity
------------
0.666667
You can find more information at http://www.postgresql.org/docs/current/static/
pgtrgm.html .
Search WWH ::




Custom Search