Re: exposing more parse was: Re: tsearch2: setting weights on tsquery

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: exposing more parse was: Re: tsearch2: setting weights on tsquery
Date: 2008-10-21 16:06:25
Message-ID: 20081021180625.4dd3c14c@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 21 Oct 2008 10:36:20 -0400
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> writes:
> > It would still be nice to be able to directly work with tsvector
> > and tsquery so people could exploit the parser, lexer etc... and
> > recycle the config.
>
> > I'd thinking something in the line of
> > for lex in select * from to_tsvector('jsjdjd fdsds')
>
> Don't the tsearch debug functions provide what you want?
> http://www.postgresql.org/docs/8.3/static/textsearch-debugging.html

I missed it. Thanks. Nearly perfect. Now I've to understand what a
{} is.
An array with a null element? an empty array? an array containing ''?
Since I can't
where lexemes<>'{}'::text[] and variations.

select token, lexemes from ts_debug('pg_catalog.english',
'a cat eaten on the net set eat seat ate late things'
) where array_upper(lexemes,1)>=1;

The above works as expected so it should be an empty array.

select token, lexemes from ts_debug('pg_catalog.english',
'a cat eaten on the net set eat seat ate late things'
) where lexemes<>'{}'::text[];

This doesn't (?)

I did google and I've found some of your answers about empty arrays
but none worked "embedded" directly in the sql statement.

variations of this still don't work:

create or replace function zsetweight(out _tsquery text) as
$$
declare
_tsdebug record;
_tmp text[]:='{}';
begin
_tsquery:='';
for _tsdebug in select token
from ts_debug('pg_catalog.english',
'a cat eaten on the net set eat seat ate late things'
) where lexemes<>_tmp loop
_tsquery:=coalesce(_tsquery,'') || ' | ' ||
coalesce(_tsdebug.token,'');
end loop;
return;
end;
$$ language plpgsql immutable;

select * from zsetweight();

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Teodor Sigaev 2008-10-21 16:35:54 Re: index scan leads to result that is different from sec scan after upgrading to 8.3.4
Previous Message Karl Nack 2008-10-21 15:53:35 Re: How best to implement a multi-table constraint?