Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Omar Qureshi's Profile

GitHub User: omarqureshi

Site: www.omarqureshi.net

Comments by Omar Qureshi

Avatar

The example I have is something like:

http://omarqureshi.net/articles/2010-12-25-tsearch2-for-rails-applications

I re-use the same function for inserts that i do for updates and just call it differently inside the trigger. The only real bit of duplication is the refresh function - which i have for existing content only.

Avatar

you shouldn't need pg_restore

psql has a -f switch that takes a file as an argument

Avatar

Nice!

As an aside, a tend to create a tsv column for any models that I'm going to be having a full text search on and using before update / insert triggers for maintenance.

This way, the expense of the to_tsvector happens only on writes and I don't need to have multiple indexes, just the one index on the whole vector.

Obviously this is not the solution for a volatile schema as you'll need to recreate the triggers and recreate the tsv column if you want to search for more things, but one where the schema and search is fairly stable its ideal.