Skip to content

Instantly share code, notes, and snippets.

@athoune
Created January 12, 2012 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athoune/1600559 to your computer and use it in GitHub Desktop.
Save athoune/1600559 to your computer and use it in GitHub Desktop.
crash ES with the ! character
#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!"}}}'
@karmi
Copy link

karmi commented Jan 12, 2012

You have to escape the query strings, search "Lucene query syntax".

@athoune
Copy link
Author

athoune commented Jan 13, 2012

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