Re: Tsearch2 lexeme position - Mailing list pgsql-general

From Alexander Rüegg
Subject Re: Tsearch2 lexeme position
Date
Msg-id 3F3A60FD.3090405@uni-bielefeld.de
Whole thread Raw
In response to Re: Tsearch2 lexeme position  (Teodor Sigaev <teodor@sigaev.ru>)
Responses Re: Tsearch2 lexeme position
List pgsql-general
Thank you for your response.
We want to know the distance or sequence of words in a set of
text-entries. So first we try to retrieve the text-entries in which the
words appear using tsearch indexing. After that we want to calculate the
positions of the words in each entry, e.g. parsing the index column of
the retrieved text-entries.
Maybe there exists a function or an easier/cheaper way to get this
information (and which considers that the words maybe occur more than once).

thanks,
Alex

Teodor Sigaev wrote:

>
>
> Alexander Rüegg wrote:
>
>> Hi,
>>
>> Is it possible to get all the positions of a lexeme in a result-set of a
>> query? For example, we have the table
>>
>> TEXT                                                   TEXT_IDX
>> 'TSearch2 is very cool'                                ...
>>
>> 'It would be much cooler with lexeme positions'
>>
>> Our query is
>> SELECT text, position FROM thetable WHERE  text_idx @@ 'cool'::tsquery;
>>                          ^^^^^^^^
>> The result should be something like:
>> 'TSearch2 is very cool', 4
>> 'It would be much cooler with lexeme positions', 5
>>
>> If not, is there a function that returns the positions of a lexeme in a
>> single entry?
>>
>
> You can write such function, but why do you need it? May be there is
> more simple way to resolve your problem?
>
> BTW, lexeme can have more that one position...
>
>
>
--

Alexander Rueegg
Email: arueegg@uni-bielefeld.de



pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: Re: Sorting Problem
Next
From: Stephan Szabo
Date:
Subject: Re: Sorting Problem