pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to write UDF in C that resemble the LIKE function
3+ messages / 3 participants
[nested] [flat]

* How to write UDF in C that resemble the LIKE function
@ 2005-02-13 03:40 b t <qtboyzz@yahoo.com>
  2005-02-13 04:07 ` Re: How to write UDF in C that resemble the LIKE function Tom Lane <tgl@sss.pgh.pa.us>
  2005-02-13 04:07 ` Re: How to write UDF in C that resemble the LIKE function Michael Fuhr <mike@fuhr.org>
  0 siblings, 2 replies; 3+ messages in thread

From: b t @ 2005-02-13 03:40 UTC (permalink / raw)
  To: pgsql-interfaces

First of all thanks to those who take time to reply to my message.
 
I have a question, as part of the project that I have to do for school, we have to implement a User Define Function in C that is similar like the LIKE funtion in PostgreSQL. For example where a customer is searching for an actor whose last name sounds like "Schwarseneger" (notice the typo). However, the customer is not sure neither about the spelling nor the pronunciation. The real star name should be "Schwarzenegger". In this case, the "LIKE" operator in SQL is not capable enough. It would be nice if the search would match last names "similar to" "Schwarseneger". Can Some one please give me some pointer on this or even sample code that you might have implemented. So basically the thing that I'm doing is like a spell check system where it return the closest match to the word.
 
Thanks in advance
-Brian Trinh 


		
---------------------------------
Do you Yahoo!?
 Yahoo! Search presents - Jib Jab's 'Second Term'

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to write UDF in C that resemble the LIKE function
  2005-02-13 03:40 How to write UDF in C that resemble the LIKE function b t <qtboyzz@yahoo.com>
@ 2005-02-13 04:07 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2005-02-13 04:07 UTC (permalink / raw)
  To: b t <qtboyzz@yahoo.com>; +Cc: pgsql-interfaces

b t <qtboyzz@yahoo.com> writes:
> I have a question, as part of the project that I have to do for
> school, we have to implement a User Define Function in C that is
> similar like the LIKE funtion in PostgreSQL. For example where a
> customer is searching for an actor whose last name sounds like
> "Schwarseneger" (notice the typo). However, the customer is not sure
> neither about the spelling nor the pronunciation. The real star name
> should be "Schwarzenegger". In this case, the "LIKE" operator in SQL
> is not capable enough. It would be nice if the search would match last
> names "similar to" "Schwarseneger". Can Some one please give me some
> pointer on this or even sample code that you might have
> implemented. So basically the thing that I'm doing is like a spell
> check system where it return the closest match to the word.

Didn't your professor notice that there are two or three of those
already in contrib/fuzzystrmatch?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to write UDF in C that resemble the LIKE function
  2005-02-13 03:40 How to write UDF in C that resemble the LIKE function b t <qtboyzz@yahoo.com>
@ 2005-02-13 04:07 ` Michael Fuhr <mike@fuhr.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Michael Fuhr @ 2005-02-13 04:07 UTC (permalink / raw)
  To: b t <qtboyzz@yahoo.com>; +Cc: pgsql-interfaces

On Sat, Feb 12, 2005 at 07:40:17PM -0800, b t wrote:
>  
> I have a question, as part of the project that I have to do for school,
> we have to implement a User Define Function in C that is similar like the
> LIKE funtion in PostgreSQL. For example where a customer is searching for
> an actor whose last name sounds like "Schwarseneger" (notice the typo).
> However, the customer is not sure neither about the spelling nor the
> pronunciation. The real star name should be "Schwarzenegger".

The contrib/fuzzystrmatch module contains implementations of the
soundex, levenshtein, and metaphone algorithms.  Here's an example:

CREATE TABLE actor (
    id    serial PRIMARY KEY,
    name  text NOT NULL
);

INSERT INTO actor (name) VALUES ('Schwarzenegger');

SELECT * FROM actor WHERE soundex(name) = soundex('Schwarseneger');
 id |      name      
----+----------------
  1 | Schwarzenegger

You could create a functional index to speed up queries on large
tables:

CREATE INDEX actor_name_soundex_idx ON actor (soundex(name));

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-02-13 04:07 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-13 03:40 How to write UDF in C that resemble the LIKE function b t <qtboyzz@yahoo.com>
2005-02-13 04:07 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-02-13 04:07 ` Michael Fuhr <mike@fuhr.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox