Tsvectors for multiple search methods

117 views
Skip to first unread message

darrenb...@gmail.com

unread,
Feb 20, 2015, 8:08:37 PM2/20/15
to casecom...@googlegroups.com
I'm trying to setup tsvector columns for a scope search with tsearch, trigram, and dmetaphone.  The documentation says:


  • Create a column of type tsvector that you'd like to search against. If you want to search using multiple search methods, for example tsearch and dmetaphone, you'll need a column for each.
  • Create a trigger function that will update the column(s) using the expression appropriate for that type of search. See: the PostgreSQL documentation for text search triggers
What is the purpose of setting up multiple tsvector columns vs just having one and using it for each type of search? I understand how to build a tsvector for tsearch from the docs, but how do you go about setting up a trigger expression for a dmetaphone?  


Grant Hutchins

unread,
Feb 27, 2015, 10:35:08 PM2/27/15
to casecom...@googlegroups.com
We have a (somewhat incomplete) wiki page about building indexes.

You will want to make a tsvector based on each expression that pg_search generates for your document. So you might notice that the expression for the dmetaphone part includes a call to pg_search_dmetaphone() mixed in somewhere between all the to_tsvector calls, the coalesce calls, any unaccent() calls, etc.

The main reason you need to have separate tsvectors is that the different expressions for the document part of the @@ parts of the where clause end up generating completely different tsvectors.

I hope this helps, I know it's a bit esoteric. Feel free to ask follow-up questions.

--

---
You received this message because you are subscribed to the Google Groups "Case Commons Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to casecommons-d...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

blev...@mdsol.com

unread,
Sep 11, 2015, 4:32:59 PM9/11/15
to Case Commons Development, gr...@nertzy.com


I have the same question. It's not clear to me what the expression should be for a dmetaphone tsvector column. Is there an example somewhere that shows what the trigger code should be? Thanks!
Reply all
Reply to author
Forward
0 new messages