Re: exposing more parse was: Re: tsearch2: setting weights on tsquery - Mailing list pgsql-general

From Ivan Sergio Borgonovo
Subject Re: exposing more parse was: Re: tsearch2: setting weights on tsquery
Date
Msg-id 20081021180625.4dd3c14c@dawn.webthatworks.it
Whole thread Raw
In response to Re: exposing more parse was: Re: tsearch2: setting weights on tsquery  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: exposing more parse was: Re: tsearch2: setting weights on tsquery  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Tue, 21 Oct 2008 10:36:20 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Ivan Sergio Borgonovo <mail@webthatworks.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


pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Annoying Reply-To
Next
From: "Karl Nack"
Date:
Subject: Re: How best to implement a multi-table constraint?