Re: Avoiding empty queries in tsearch

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Doug Cole <doug(at)shackprices(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Avoiding empty queries in tsearch
Date: 2007-01-15 19:09:08
Message-ID: 45ABD154.50800@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Doug Cole wrote:
> That sounds perfect, but it doesn't seem to exist on either of the
> postgresql installations I have access to (8.1 on ubuntu and fedora
> core). Is it new to 8.2? Is there a similar function under 8.1, or at
Yes, it's new in 8.2

> least a decent work-around? Thanks for the help,
> Doug

Not nice workaround but it works:

# create or replace function isvoid(tsquery)
returns bool as $$
select case when $1 is NULL then 't'::bool when length(textin(tsquery_out( $1
))) = 0 then 't'::bool else 'f'::bool end;
$$ language SQL called on null input;

# select isvoid( plainto_tsquery('the & any') );
NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored
isvoid
--------
t
(1 row)

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2007-01-15 19:09:52 Re: Avoiding empty queries in tsearch
Previous Message Doug Cole 2007-01-15 19:03:29 Re: Avoiding empty queries in tsearch