tsearch2: setting weights on tsquery

Поиск
Список
Период
Сортировка
От Ivan Sergio Borgonovo
Тема tsearch2: setting weights on tsquery
Дата
Msg-id 20081021102952.420deb9a@dawn.webthatworks.it
обсуждение исходный текст
Ответы exposing more parse was: Re: tsearch2: setting weights on tsquery
Список pgsql-general
plainto_tsquery is handy to make a string from users turn into a
tsquery.

This strips "control" characters and glue lexemes with &.

Now I've several strings coming from input user and what I'd like to
do is assign a different token to each part.

eg.
input1 = "ratto && matto | gatto & the"
input2 = "sasso|&passo lasso a"
->
tsquery = 'ratto:A & matto:A & gatto:A & sasso:B & passo:B & lasso:B'

I could prepare the input outside postgresql and then
"concatenate" the queries but plainto_tsquery is very comfortable
since it will always actually "clean up" the right way the input and
adds & at the right place.

Otherwise I could use more than one tsvector for searching input1
and input2 but it seems it is slower than
update t1 set FT1IDX=(

setweight(to_tsvector('pg_catalog.english',
coalesce(input1,'')), 'A') || ' ' ||

setweight(to_tsvector('pg_catalog.english',
coalesce(input2,'')), 'B')
)

and I won't be able rank on all fields at a time.

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


В списке pgsql-general по дате отправления:

Предыдущее
От: Zeugswetter Andreas OSB sIT
Дата:
Сообщение: Re: [HACKERS] Hot Standby utility and administrator functions
Следующее
От: "Ruben Blanco"
Дата:
Сообщение: How to free disk space