Re: Tsearch2: casting text to tsquery

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Alexander Presber <aljoscha(at)weisshuhn(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Tsearch2: casting text to tsquery
Date: 2005-11-16 17:10:17
Message-ID: Pine.GSO.4.63.0511162006390.29329@ra.sai.msu.su
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 16 Nov 2005, Alexander Presber wrote:

>
> Am 16.11.2005 um 13:52 schrieb Oleg Bartunov:
>
>> On Wed, 16 Nov 2005, Alexander Presber wrote:
>>
>>> Hello,
>>>
>>> I have a question that arose while using tsearch on a large database of
>>> book information.
>>>
>>> In order to inject unstemmed + stemmed versions of searchstrings into a
>>> query we want to cast an expression of type text to tsquery.
>>> Unfortunately
>>>
>>> SELECT 'word'::tsquery
>>>
>>> (where the literal 'word' is of type 'unknown' seemingly) works just fine
>>> while e.g.
>>>
>>> SELECT ('word' || '&fullword')::tsquery
>>>
>>> or, simpler
>>>
>>> SELECT 'word&fullword'::text::tsquery
>>>
>>> gives
>>>
>>> ERROR: cannot cast type text to tsearch2.tsquery
>>>
>>> How can we work around that? Thanks for any help
>>
>> no workaround needed. to_tsquery provides everything you need. If you want
>> fancy-shmancy solution you could always write wrapper around tsquery, but
>> I doubt you enter queries by hand, so why do you bothering ?
>
> No. No fancy-shmancy solution needed, just one that works.
>
> I do not see a way to include both a stemmed and unstemmed version of a
> string into a tsquery.
> Can you give an example, please?

This is quite different question and Teodor has already answered you -
use different configurations. But I'm wondering why do you need that.

>
> Thanks
> Alex
>
> P.S. I have read the documentation (twice.)
>
>>>
>>> Sincerely yours
>>> Alexander Presber
>>>
>>>
>>>
>>>
>>> ---------------------------(end of broadcast)---------------------------
>>> TIP 6: explain analyze is your friend
>>
>> Regards,
>> Oleg
>> _____________________________________________________________
>> Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
>> Sternberg Astronomical Institute, Moscow University (Russia)
>> Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
>> phone: +007(095)939-16-83, +007(095)939-23-83
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match

Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2005-11-16 17:12:42 Re: Rebranding PostgreSQL
Previous Message Bruce Momjian 2005-11-16 17:05:36 Re: Rebranding PostgreSQL