Re: Fragments in tsearch2 headline - Mailing list pgsql-general

From Catalin Marinas
Subject Re: Fragments in tsearch2 headline
Date
Msg-id b0943d9e0710300341h34d68bbp4a717d681b769b3f@mail.gmail.com
Whole thread Raw
In response to Re: Fragments in tsearch2 headline  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: Fragments in tsearch2 headline  (Oleg Bartunov <oleg@sai.msu.su>)
List pgsql-general
On 28/10/2007, Oleg Bartunov <oleg@sai.msu.su> wrote:
> On Sat, 27 Oct 2007, Tom Lane wrote:
>
> > "Catalin Marinas" <catalin.marinas@gmail.com> writes:
> >> Is there an easy way to generate a headline from separate fragments
> >> containing the search words and maybe separated by "..."?
> >
> > Hmm, the documentation for ts_headline claims it does this already:
[...]
> > However, a quick look at the code suggests this is a lie --- I see no
> > evidence whatever that there's any smarts for putting in ellipses.
>
> Probably documentation is not correct here. 'ellipsis-separated' should be
> treated as a general wording. Default highlighting is <b>..</b> as it
> stated below in docs.

It seems that I'll have to implement the headline outside the query
(Python, in my case). I would use to_tsvector and to_tsquery to
generate the lexemes and the work position, add them to a hash table
and use the position of the matching lexemes to generate the headline.

I could also highlight the full text and generate the headline I want
based on it but if I limit the number of excerpts, it gets complicated
to avoid the same lexeme being shown in all excerpts. Is a lexeme
always a substring of the corresponding token (so that I can use
simple regexp)?

Any other ideas?

Thanks.

--
Catalin

pgsql-general by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: Checking empty array
Next
From: Oleg Bartunov
Date:
Subject: Re: Fragments in tsearch2 headline