Using proper SQL query to search for multiple search words.
This commit is contained in:
parent
ee530072eb
commit
d1d4cea63a
1 changed files with 3 additions and 1 deletions
|
|
@ -12,7 +12,9 @@ class Package < ActiveRecord::Base
|
|||
RANK
|
||||
|
||||
# Do the full-text search and return results by rank
|
||||
where("packages.name @@ :q or packages.description @@ :q", q: query).order("#{rank} desc")
|
||||
where("to_tsvector('english', packages.name) @@ plainto_tsquery(:q) or
|
||||
to_tsvector('english', packages.description) @@ plainto_tsquery(:q)
|
||||
", q: query).order("#{rank} desc")
|
||||
else
|
||||
scoped
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue