Created
January 12, 2012 13:35
-
-
Save athoune/1600559 to your computer and use it in GitHub Desktop.
crash ES with the ! character
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require 'rubygems' | |
require 'tire' | |
require 'json' | |
require 'active_support/core_ext/object/to_query' | |
require 'active_support/core_ext/object/to_param' | |
Tire.configure { logger 'elasticsearch.log', :level => 'debug' } | |
Tire.index 'ponctu' do | |
delete | |
create | |
import [ | |
{id:1, text:"Hello!"} | |
] | |
refresh | |
end | |
s = Tire.search 'ponctu' do | |
query do | |
#Crash without the escape paramater | |
string 'Hello!', escape: true | |
end | |
end | |
s.results.each do |document| | |
p document.text | |
end | |
# curl -X GET "http://localhost:9200/ponctu/_search?pretty=true" -d '{"query":{"query_string":{"query":"Hello!"}}}' |
It works well with string 'Hello!', escape: true
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to escape the query strings, search "Lucene query syntax".