Sunday, 12 September 2010

fuzzymatching in postgres on ubuntu

I had a battle getting the soundex function installed into my database on postgres.
but here's how I succeeded.

One - Install the postgres-contrib package
sudo apt-get install  postgresql-contrib

Two - change user to postgres (a database superuser created on install of postgresql
neil@slim-maroon:~$ sudo su - postgres
postgres@slim-maroon:~$ 

Three - pipe the supplied script into the database (my database is called "openmolar_demo")
postgres@slim-maroon:~$ psql -d openmolar_demo -f /usr/share/postgresql/8.4/contrib/fuzzystrmatch.sql
SET
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
postgres@slim-maroon:~$

Four - test it!
openmolar_demo=> SELECT soundex('Neil');
 soundex 
---------
 N400
(1 row)

No comments: