"Peter Eisentraut" <peter_e@gmx.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!