Skip to content
Advertisement

Similarity function in Postgres with pg_trgm

I’m trying to use the similarity function in Postgres to do some fuzzy text matching, however whenever I try to use it I get the error:

If I add explicit casts to text I get the error:

My query is:

Do I need to do something to initalize pg_trgm?

Advertisement

Answer

You have to install pg_trgm. In debian, source this sql: /usr/share/postgresql/8.4/contrib/pg_trgm.sql. From the command line:

Or inside a psql shell:

The script defaults to installing in the public schema, edit the search path at the top if you want to install it somewhere else (so that uninstalling/upgrading can be done simply by dropping the schema).

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement