Single Quote in tsquery

Lists: pgsql-sql
From: Ryan Wallace <rywall(at)interchange(dot)ubc(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Single Quote in tsquery
Date: 2008-08-05 17:19:02
Message-ID: 16624100.9551217956742881.JavaMail.myubc2@brahms.my.ubc.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hi all,

I am trying to perform a full text search for the word 'ksan (which starts with a quote). After much frustration and syntax errors I stumbled upon the following statement which seems to work:

select *
from items
where to_tsvector(name) @@ to_tsquery(E'[\']ksan')

I would like to know if this is actually the correct way to search for this word? The use of brackets isn't documented anywhere that I can find so I'm not sure if it is even doing what I want it to do or if the correct result is just a coincidence.

Thanks,
Ryan


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Ryan Wallace <rywall(at)interchange(dot)ubc(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Single Quote in tsquery
Date: 2008-08-06 22:18:49
Message-ID: 20080806221849.GA3676@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Ryan Wallace wrote:

> I am trying to perform a full text search for the word 'ksan (which
> starts with a quote). After much frustration and syntax errors I
> stumbled upon the following statement which seems to work:
>
> select *
> from items
> where to_tsvector(name) @@ to_tsquery(E'[\']ksan')
>
> I would like to know if this is actually the correct way to search for
> this word? The use of brackets isn't documented anywhere that I can
> find so I'm not sure if it is even doing what I want it to do or if
> the correct result is just a coincidence.

I think the tsearch grammar supports something it calls "simplified
regular expressions" or some such, which includes character classes
(delimited by brackets). So it would seem that what you show is
actually supported and correct.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.