Re: fts, compond words?

From: Marcus Engene <mengpg(at)engene(dot)se>
To: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>, pgsql-general(at)postgresql(dot)org
Subject: Re: fts, compond words?
Date: 2005-12-06 11:44:27
Message-ID: 4395799B.7080406@engene.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oleg Bartunov wrote:
> On Mon, 5 Dec 2005, Marcus Engene wrote:
>> I realized from the documentation that I'm not looking for
>> compound words after all, I meant "exact phrase".
>>
>> I can't see how to make rank tell me which results has an
>> exact phrase? Like "there must be a occurence of 'new' before
>> 'york'" (stemmed not really exact phrase)?
>
> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes
>
> Phrase search
> This tip is by Mike Rylander
>
> To do phrase searching just add an additional WHERE clause to your query:
>
> SELECT id FROM tab WHERE ts_idx_col @@ to_tsquery('history&lesson')
> AND text_col ~* '.*history\\s+lesson.*';
>
> The full-text index will still be used, and the regex will be used to
> prune the results afterwards.

Hi,

Thanks for the answer, Oleg and Mike.

This, I guess, will be problematic in a query like
A & (B | C)
or a more complex expression.

say C is "New York" and that tsearch receives

A & (B | (new & york))

I cannot just add the regexp afterwards. What if B is true?
What would be nice to have, given ofcourse the index isn't stripped
is something like

A & (B | (New OperatorTheNextWordMustFollow York))

Would something like that be doable? Right now, intuitively, it would be
two trees in the where clause:
tsearch(A & B) OR
(tsearch (A & C) AND regexpmatch(C))
..and a nightmare in complex queries.

Best regards,
Marcus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karthik.S 2005-12-06 12:26:20 error in creating database
Previous Message Alban Hertroys 2005-12-06 10:45:48 Re: need help