From: | Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> |
---|---|
To: | Catalin Marinas <catalin(dot)marinas(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org, Teodor Sigaev <teodor(at)sigaev(dot)ru> |
Subject: | Re: Fragments in tsearch2 headline |
Date: | 2007-10-30 10:52:07 |
Message-ID: | Pine.LNX.4.64.0710301350190.14368@sn.sai.msu.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Catalin,
what is your need ? What's wrong with this ?
postgres=# select ts_headline('1 2 3 4 5 3 4 abc abc 2 3 xyz','2'::tsquery, 'StartSel=...,StopSel=...')
;
ts_headline
-------------------------------------------
1 ...2... 3 4 5 3 4 abc abc ...2... 3 xyz
Oleg
On Tue, 30 Oct 2007, Catalin Marinas wrote:
> On 28/10/2007, Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> wrote:
>> On Sat, 27 Oct 2007, Tom Lane wrote:
>>
>>> "Catalin Marinas" <catalin(dot)marinas(at)gmail(dot)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.
>
>
Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru)
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2007-10-30 11:05:09 | Re: Fragments in tsearch2 headline |
Previous Message | Catalin Marinas | 2007-10-30 10:41:27 | Re: Fragments in tsearch2 headline |