Re: Question about fulltext search and to_tsvector function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Question about fulltext search and to_tsvector function
Дата
Msg-id 8030.1224216153@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Question about fulltext search and to_tsvector function  (Mike Christensen <imaudi@comcast.net>)
Список pgsql-general
Mike Christensen <imaudi@comcast.net> writes:
> This is exactly what you would do as well?  I just want to make sure
> this isn't considered a hack..

It certainly works.  What the docs seem to recommend though is
concatenating the *output* of to_tsvector applied to each field,
along the lines of

   setweight(to_tsvector('pg_catalog.english', coalesce(new.title,'')), 'A') ||
   setweight(to_tsvector('pg_catalog.english', coalesce(new.body,'')), 'D');

(cf. section 12.4.3 in the 8.3 docs).  I'm not sure about whether this
is better or worse from a micro-optimization speed point of view, but
the reason to do it this way is you can attach different weights to
words from different fields, as illustrated above.  That can come in
handy in future searching.

(Note that || applied to tsvectors isn't really just simple
concatenation, but that's the operator name that was chosen.)

            regards, tom lane

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Question about NOT NULL and default values.
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: Question about NOT NULL and default values.