You are not running into an html-escaping issue. raw
and html_safe
are only useful when you don't want output escape when printed directly to a user's browser. For instance, the params would output q=asa&pretty=true
if you were running into an html-escaping problem, but you are not.
What you are seeing is the results of CGI.escape
which outputs url-safe values.
It looks to me (based on your current use of the search
method), that the hash options get translated to query params. Have you tried this:
@esearch.search q: params[:query], pretty: true
I'm not sure what search
is doing, but this seems like an odd method to be using directly in your view. Of course I could be wrong on that since I don't know exactly what it's doing.
UPDATE:
Check out the documentation here: https://github.com/elasticsearch/elasticsearch-ruby/blob/master/elasticsearch-api/lib/elasticsearch/api/actions/search.rb#L15
There's two ways of sending query params, it looks like. One is with that q: 'title:text'
format which is what you're sending your params[:query]
(but it looks like your query is just 'asa' so I'm not sure you're even using the right format there?) with, and the other is through the body
hash:
@esearch.search body: {
query: { match: { title: 'test' } },
facets: { tags: { terms: { field: 'tags' } } }
}
You should look through that documentation including the links to the elastic search options documentation and figure out what you need to send it. I don't see that pretty: true
option in the docs so not sure what that's for. But there's a lot of docs and I didn't really look at them extensively, I'll leave that up to you.