I am having a elastic search node with the following default config
index :
analysis :
analyzer :
default_index :
type : custom
tokenizer : whitespace
filter :
- lowercase
- asciifolding
- stop
- my_ngram
char_filter : html_strip
default_search:
type : custom
tokenizer : whitespace
filter:
- lowercase
- asciifolding
- stop
char_filter : html_strip
filter:
my_ngram:
type: nGram
max_gram: 50
I then create a index "test"
curl -XPUT localhost:9200/test -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
}'
I posted
curl -XPOST localhost:9200/test/sub -d '{"n1" : "so?:me"}'
search as
curl -XPOST 'localhost:9200/test/sub/_search?pretty&q=\?'
and I get the right result with the above entry shown, but when I do
curl -XPOST localhost:9200/test/sub/_search -d '{
"query": {
"query_string": {
"query": "\?"
}
}
}'
I get an exception as below
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure;
shardFailures {[1fLLfu79Qou8RbdrI6y8qw][test][0]:
SearchParseException[[test][0]: from[-1],size[-1]:
Parse Failure [Failed to parse source [
{
"query": {
"query_string": {
"query": "\\?"
}
}
}
]]];
nested: QueryParsingException[[test] Failed to parse];
nested: JsonParseException[Unrecognized character escape '?' (code 63)\n at [Source: [B@1601cda; line: 1, column: 45]]; }]",
"status": 500
}
I am not sure what I am missing here?
some more detail, I found and it's more confusing.
if I post
curl -XPOST localhost:9200/test/sub/_search -d '{
"query": {
"query_string": {
"query": "\\?"
}
}
}'
I get the result back, properly, looks like the JSON escape character has to be escaped itself. but then I post
curl -XPOST localhost:9200/test/sub -d '{"n1" : "oi\\me"}'
and now if I post
curl -XPOST localhost:9200/test/sub/_search?pretty -d '{
"query": {
"query_string": {
"query": "\\\\"
}
}
}'
I get the result, assuming what I found previously the above represents just the first '\' in the answer it shows so ideally
curl -XPOST localhost:9200/test/sub/_search?pretty -d '{
"query": {
"query_string": {
"query": "\\\\\\\\"
}
}
}'
should work but it doesn't. so very confused.