[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

How to do a soundslike database query

Does Postgre have a way of doing a database search query similar to SOUNDEX? Like finding results that "soundlike" or are "closeto" what the person search for??

If so, how is it done or how can it be done?
0
cimmer
Asked:
cimmer
  • 2
1 Solution
 
earth man2Commented:
see postgresql-8.0.0beta4/contrib/fuzzystrmatch/README.soundex
0
 
earth man2Commented:
cd postgresql-8.0.0beta4/contrib/fuzzystrmatch
make

bash-2.05a$ pg_config --pkglibdir
/usr/lib/postgresql

copy libfuzzystrmatch.so `pg_config --pkglibdir`

dev=# CREATE FUNCTION levenshtein (text,text)
dev-# RETURNS int
dev-# AS '$libdir/libfuzzystrmatch','levenshtein'
dev-# LANGUAGE 'C' WITH (iscachable, isstrict);
CREATE FUNCTION
dev=#
dev=# CREATE FUNCTION metaphone (text,int)
dev-# RETURNS text
dev-# AS '$libdir/libfuzzystrmatch','metaphone'
dev-# LANGUAGE 'C' WITH (iscachable, isstrict);
CREATE FUNCTION
dev=#
dev=# CREATE FUNCTION soundex(text) RETURNS text
dev-# AS '$libdir/libfuzzystrmatch', 'soundex'
dev-# LANGUAGE 'C' WITH (iscachable, isstrict);
ERROR:  function "soundex" already exists with same argument types
dev=#
dev=# CREATE FUNCTION text_soundex(text) RETURNS text
dev-# AS '$libdir/libfuzzystrmatch', 'soundex'
dev-# LANGUAGE 'C';
CREATE FUNCTION
dev=#
dev=# CREATE FUNCTION dmetaphone (text) RETURNS text
dev-# LANGUAGE C IMMUTABLE STRICT
dev-# AS '$libdir/libfuzzystrmatch', 'dmetaphone';
CREATE FUNCTION
dev=#
dev=# CREATE FUNCTION dmetaphone_alt (text) RETURNS text
dev-# LANGUAGE C IMMUTABLE STRICT
dev-# AS '$libdir/libfuzzystrmatch', 'dmetaphone_alt';
CREATE FUNCTION

dev=# select soundex( 'joan' ) = soundex( 'john' );
 ?column?
----------
 t
(1 row)
dev=# select dmetaphone( 'bow' ) = dmetaphone( 'bough' );
 ?column?
----------
 t

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now