Do I put it in each model, right before, multisearchable :against => [ ... ] or should this be in a separate file? Thanks.
Where do I put PgSearch.multisearch_options?
972 Views Asked by oort At
2
There are 2 best solutions below
0
On
I had similar questions about how to implement PgSearch.multisearch_options.
This is what worked for me. Hopefully it will help someone else out.
I created the Initializer config/initializers/pg_search.rb
PgSearch.multisearch_options = {
:using => {
:tsearch => {
:dictionary => "english"
}
}
}
In my application.rb file I uncommented this line: config.active_record.schema_format = :sql
Then created a migration called rails g migration add_trigram_extension adding the below to the migration file
def up
execute "create extension pg_trgm"
end
def down
execute "drop extension pg_trgm"
end
Then run bundle exec rake db:migrate
Restart the server
Now full text search with Stemming is working.
p.s. this worked using (PostgreSQL) 9.1.4
Okay found the answer, so I'll post it below.
I created a file called
config/initializers/pg_search.rbwhich looks like:I don't fully understand why
:trigram => {}works rather than just:trigram, but I guess that should be in another post.