tsearch comments - Mailing list pgsql-general

From Björn Metzdorf
Subject tsearch comments
Date
Msg-id 01bf01c2c267$b1643670$0564a8c0@shock
Whole thread Raw
List pgsql-general
Hi,

I was browsing the archives for anything related to tsearch and stumbled
across a post from Christopher Kings-Lynne in Nov 2002. He suggested to have
txt2txtidx as an index function, but he had some problems implementing his
idea.

But his idea works very fine. Just apply the attached patch (against 7.3.1),
install tsearch as normal, and then

CREATE INDEX my_test_idx ON mytable using gist(txt2txtidx(mycolumn));

assuming "mycolumn" is a text-type column.

Then you can search "mycolumn" with

SELECT * FROM mytable WHERE txt2txtidx(mycolumn) ## 'patch&gist';

This method has several advantages:

- you don't have to extend your table with another column
- pg_dump's output won't be bloated
- you don't have to use a special trigger, the index keeps itself up to
date!

Besides, we tested tsearch also with arabian and chinese input, and it works
perfectly with unicode databases as well (although it must be the exact same
phrase, since the builtin stemmer cannot stem chinese :).

Oleg: Can you search your memory why txt2txtidx possibly should not be
marked as "iscachable"?
The rest: Is there perhaps a problem with this approach that I am not aware
of?

Regards,
Bjoern

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Re agregates
Next
From: Björn Metzdorf
Date:
Subject: Re: tsearch comments