Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 21 Oct 2008 10:36:20 -0400
Tom Lane <tgl@xxxxxxxxxxxxx> wrote:

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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux