pg-search

pg_search for an advanced search

谁都会走 提交于 2021-02-11 05:52:43
问题 I'm trying to figure out how to pass multiple parameters to my search using pg_search_gem and the pg_search_scope This is my simple search include PgSearch pg_search_scope :simple_search, against: [:title, :description], using: { tsearch: { dictionary: "spanish"} } def self.search(search) if search.present? simple_search(search) else find(:all) end end But now I'm trying to do something like this include PgSearch pg_search_scope :simple_search, against: [:title, :place, :category], using: {

pg_search for an advanced search

狂风中的少年 提交于 2021-02-11 05:51:27
问题 I'm trying to figure out how to pass multiple parameters to my search using pg_search_gem and the pg_search_scope This is my simple search include PgSearch pg_search_scope :simple_search, against: [:title, :description], using: { tsearch: { dictionary: "spanish"} } def self.search(search) if search.present? simple_search(search) else find(:all) end end But now I'm trying to do something like this include PgSearch pg_search_scope :simple_search, against: [:title, :place, :category], using: {

How to Link PGSeaerch results to Index Page in Nested Resources?

ぐ巨炮叔叔 提交于 2019-12-30 11:52:37
问题 I finally figured out how to implement pg_search's multisearch feature. But I'm having trouble making a usable search page that displays links back to the appropriate nested pages. How can I pass the proper id so I could link to the nested views. So something like this link_to myapp.com/artists/1/albums So far I get this error(i cant seem to pass the artist id) No route matches {:controller=>"albums", :artists=>nil} New to Rails Please help :) CONTROLLERS class ResultsController <

Proper full text index Rails/PostgreSQL/pg_search

a 夏天 提交于 2019-12-30 04:20:05
问题 I am testing performance for PostgreSQL full text search (using pg_search gem) and solr (sunspot_solr gem). For 4 million records I am getting 13456 ms for Tsearch and 800 ms with SOLR (that is SOLR query + DB retrival). It is obvious that I need index but I am not sure how to create one for full text search. I investigated and found that for full text search I should use GIN index. execute "CREATE INDEX products_gin_title ON products USING GIN(to_tsvector('english', title))" But I am

Why can't I save an object with a serialized attribute?

▼魔方 西西 提交于 2019-12-24 14:09:05
问题 I have... /app/models/search.rb : serialize :result def multisearch self.result = PgSearch.multisearch(self.term) self.status = "closed" self.save return result end /db/schema.rb : create_table "searches", :force => true do |t| t.string "term" t.string "status" t.text "result" end I get the following error when I try `self.save? ArgumentError: wrong number of arguments (2 for 1) from /Users/steven/.rvm/gems/ruby-1.9.2-p320/gems/arel-3.0.2/lib/arel/expressions.rb:3:in `count' I get a similar

How to show excerpts from pg-search multisearch results

泄露秘密 提交于 2019-12-22 01:29:26
问题 I've set up pg_search in my Rails app on Heroku: @query = 'fast' PgSearch.multisearch(@query) #=> [#<PgSearch::Document searchable: ferrari, :content: 'this car is really fast'>, #<PgSearch::Document searchable: viper, :content: 'a very fast car'>] I'd like to display these results with excerpts from content to show where the match occurs. I can call excerpt(content, @query) to get exactly what I want when @query is only one word, but excerpt() only handles exact matches, so if: @query = 'car