Обсуждение: I still didn't get how tsquery is internally

Поиск
Список
Период
Сортировка

I still didn't get how tsquery is internally

От
Ivan Sergio Borgonovo
Дата:
I've been working on this
http://pgsql.privatepaste.com/2a81432f4f

for 8.3 (there should be some comments to port it to 8.4).

tsvector_tsquery_size works as expected.

But whatever I pass to the function I get an empty tsquery. Yet no
memory allocation problem or hang etc... just an empty vector, but
that's not enough to say I'm not filling distance and left with the
wrong values etc... anyway.

CREATE OR REPLACE FUNCTION tsvector_to_tsquery(IN tsv tsvector, op
IN char(1), weights IN varchar(4), maxpos IN smallint)RETURNS tsqueryAS 'MODULE_PATHNAME'LANGUAGE C STRICT;

The function should turn a tsvector into a tsquery.

op is the operator (| or &)
weights is a filter. lexemes wil be picked up just if they don't
have a position/weight or they have one of the passed weights.
maxpos will filter out all lexemes that have a position>maxpos.

So

tsvector_to_tsquery('java:1A,2B tano:3C,4D', '&', 'ABC', 100) ->

java:A & java:B & tano:C

tsvector_to_tsquery('java:1A,2B tano:3C,4D', '|', 'ABC', 100) ->

java:AB | tano:C


There is also a small problem. The op is always char = 0x08 (even on
a much simpler function that just retrieve op and return it as a
masked int64.
It seems that
char op = PG_GETARG_CHAR(1);
is not really what I thought it to be.

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