Thread: tsearch2

tsearch2

From
"Chris Hoover"
Date:
I have some general questions on tsearch2. 

How do you set it up to search for "how now brown cow" vs how now brown cow?  The first example is looking for the exact phrase of words, while the second is just looking for all of the works.

Secondly, if you want to split a text field based on multiple delimiters (i.e. a text line with "johnny bravo,123 bravo ln,apple), do you have to write the parser, or is there a way to pass the parser a ' ' and a ',' as the word delimiters?

Thanks,

Chris

Re: tsearch2

From
John DeSoi
Date:
On Jun 14, 2006, at 6:29 PM, Chris Hoover wrote:

> How do you set it up to search for "how now brown cow" vs how now
> brown cow?  The first example is looking for the exact phrase of
> words, while the second is just looking for all of the works.

Your select would have two conditions, one to find rows with the
words using the tsearch2 index and then a filtering condition (e.g.
AND like '%how now brown cow%'). How effective this is depends a lot
on your data, but it works well as long as the indexed search can
return a reasonably small set for the sequential scan on the
filtering condition.

There is an example in the documentation if you need more details.


John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL