Re: Simplifying Text Search

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Peter Eisentraut" <peter_e(at)gmx(dot)net>
Cc: <pgsql-hackers(at)postgresql(dot)org>, "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Aidan Van Dyk" <aidan(at)highrise(dot)ca>, "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Simplifying Text Search
Date: 2007-11-13 12:13:26
Message-ID: 87wssmjqc9.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


"Peter Eisentraut" <peter_e(at)gmx(dot)net> writes:

> What we'd need is a way to convert a LIKE pattern into a tsquery ('%foo%bar%'
> => 'foo & bar'). Then you might even be able to sneak index-optimized text
> search into existing applications. Might be worth a try.

I don't think that's the right direction to go. Notably "%foo%bar%" isn't the
same thing as "foo & bar". Also most tsearch queries can't be expressed as
LIKE patterns anyways.

What I do like is the idea of using LIKE as a model to follow for tsearch.
Make some keyword which maps to an operator. So you could do something like

WHERE col SATISFIES 'foo & bar'

which maps to @@ just as LIKE maps to ~~. This has the interesting property of
working for ltree and other data types which support the @@ operator.

Now I'm starting to wonder though. How evil would it be to just rename all the
@@ operators to ~~ ? That redefines LIKE to be a data-type-specific operation.
Effectively declaring that tsquery, lquery, et al are all analogous concepts
for LIKE patterns.

It's probably safer to come up with a new keyword for @@ and if we ever decide
to pursue a regexp data type we could define @@ for that as well which would
make that keyword an equivalent to LIKE for regexps.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2007-11-13 12:32:55 Re: Simplifying Text Search
Previous Message Peter Eisentraut 2007-11-13 11:58:43 Re: Simplifying Text Search