Search Postgresql Archives

Re: Question about fulltext search and to_tsvector function

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

 



Mike Christensen <imaudi@xxxxxxxxxxx> 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

-- 
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