Re: tsearch_core for inclusion

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: tsearch_core for inclusion
Date: 2007-03-16 15:01:09
Message-ID: 45FAB135.5000805@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Teodor Sigaev wrote:
> CREATE INDEX idxname ON tblname USING gin (textcolumn fulltext_ops);
>
> Fulltext_ops opclass parses the document similarly to_tsvector nad
> stores lexemes in gin index. It's a full equalent of
> CREATE INDEX ... ( to_tsvector( textcolumn ) )
>
> And, let we define operation text @ text, which is equivalent of text @@
> plainto_tsquery(text), so, queries will look like
> SELECT * FROM tblname WHERE textcolumn @ textquery;
>
> Fulltext_ops can speedup both operation, text @@ tsquery and text @
> text. Because gin API has extractQuery method which calls once per index
> scan and it can parse query to lexemes.
>
> Some disadvantage: with that way it isn't possible make fast ranking -
> there is no stored parsed text. And, fulltext_ops may be done for GiST
> index too, but fulltext opclass will be lossy which means slow search
> due to reparse texts for each index match.
Just a thought:

If the patch that implements the "GENERATED ALWAYS" syntax is accepted,
than creating a seperate field that hold the parsed text and an index
on that column becomes as easy as:
alter table t1 add column text_parsed generated always as to_tsvector(text);
create index idx on t1 using gin (text_parsed fulltext_ops);

I know that there is a trigger function in tsearch that support something
similar, but I really like the simplicity of the statements above.

One a related note - will to_tsvector and to_tsquery be renamed to
something like ft_parse_text() and ft_parse_query() if tsearch2 goes
into core? It seems like the "ts" part of those names would be the only
referenced left to the name "tsearch" if they are not, which could be
somewhat confusing for users.

greetings, Florian Pflug

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-03-16 15:09:27 Re: Question: pg_class attributes and race conditions ?
Previous Message NikhilS 2007-03-16 14:55:16 Re: UPDATE using sub selects