Commit 181deb8b by Truong Ba Dieu

Fix search solr with special char

parent 93747a6e
......@@ -5,7 +5,10 @@ class SolrService
def self.search(params={})
params[:page] ||= 1
keyword = params[:keyword] || ""
keyword = keyword.gsub("^", "").gsub(":", "").gsub("(", "").gsub(")", "")
['+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\'].each do |s|
keyword = keyword.gsub(s, " ")
end
solr = RSolr.connect :url => ENV["solr_url"]
res = solr.paginate params[:page], ENV["default_perpage"], 'select', :params => {:q => "*#{keyword}*"}
res["response"]["docs"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment