Using ts_vector columns on multisearch

150 views
Skip to first unread message

Herby Raynaud

unread,
Apr 27, 2012, 10:36:28 AM4/27/12
to casecom...@googlegroups.com
I've been going through the docs and the source tying to figure this out but can't seem to find a definitive answer. 

How does one configure this?  The solution  I assume is to add the ts_vector field on pg_search_documents and the trigger on the "content" field.

Is this right or is the functionality just not supported yet for multisearch.

Thanks

Grant Hutchins

unread,
May 4, 2012, 8:37:09 PM5/4/12
to casecom...@googlegroups.com
Yes, you have the right idea.

And to get the multi search to use the tsvector column, you'll need to configure it in an initializer via PgSearch.multisearch_options.

# config/initializers/pg_search.rb
PgSearch.multisearch_options = {
  :against => "content",
  :using => {
    :tsearch => {
      :tsvector_column => "tsvector_content_tsearch"
    }
  }
}

And since the :dmetaphone search is also backed by a tsvector, you may want to make a similar tsvector column that uses a trigger that calls the pg_search_dmetaphone() function before converting the content to tsvector. It's a bit more advanced, and unnecessary if :tsearch is good enough for your use. Also, the :trigram search does not use a tsvector at all.

Don't hesitate to let us know if you have any questions or run into any obstacles. Thanks!

-- 
Grant Hutchins
Pivotal Labs

Reply all
Reply to author
Forward
0 new messages