我有以下的默認配置一個彈性的搜索節點彈性搜索NGRAM特殊字符
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
我然後創建一個索引「測試」
curl -XPUT localhost:9200/test -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
}'
我張貼
curl -XPOST localhost:9200/test/sub -d '{"n1" : "so?:me"}'
搜索爲
curl -XPOST 'localhost:9200/test/sub/_search?pretty&q=\?'
和我得到顯示上述條目正確的結果,但是當我做
curl -XPOST localhost:9200/test/sub/_search -d '{
"query": {
"query_string": {
"query": "\?"
}
}
}'
我得到一個異常,如下
{
"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: [[email protected]; line: 1, column: 45]]; }]",
"status": 500
}
我不知道我在這裏失蹤?
一些更多的細節,我發現它更混亂。
如果我發佈
curl -XPOST localhost:9200/test/sub/_search -d '{
"query": {
"query_string": {
"query": "\\?"
}
}
}'
我得到的結果返回,得當,看起來像JSON轉義字符來轉義本身。但後來我發帖
curl -XPOST localhost:9200/test/sub -d '{"n1" : "oi\\me"}'
現在如果我發佈
curl -XPOST localhost:9200/test/sub/_search?pretty -d '{
"query": {
"query_string": {
"query": "\\\\"
}
}
}'
我得到的結果,假設我發現以前上面僅代表第一「\」在回答它顯示了這樣的理想
curl -XPOST localhost:9200/test/sub/_search?pretty -d '{
"query": {
"query_string": {
"query": "\\\\\\\\"
}
}
}'
應該可以工作,但它不會。所以非常困惑。