如何在elasticsearch中搜索utf-8特殊字符?

pal*_*mic 4 unicode utf-8 elasticsearch

我有一个问题是找到在弹性搜索中查询Unicode特殊字符的解决方案.

当我创建这个索引时:

curl -XPUT http://localhost:9200/index/type/1 -d '{"name" : "Vrba u ?eky"}'
Run Code Online (Sandbox Code Playgroud)

然后我试图搜索"řeky"短语,一切都OK:

curl -XGET 'http://localhost:9200/index/type/_search?pretty=1' -d '{"query" : {"text" : 

{ "_all" : "?eky" }}}'

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.10848885,
    "hits" : [ {
      "_index" : "index",
      "_type" : "type",
      "_id" : "1",
      "_score" : 0.10848885, "_source" : {"name" : "Vrba u ?eky"}
    } ]
  }
}
Run Code Online (Sandbox Code Playgroud)

但当我尝试搜索同一个单词时,我找不到任何东西:

curl -XGET 'http://localhost:9200/index/type/_search?pretty=1' -d '{"query" : {"text" : { "_all" : "\\u0159eky" }}}'
Run Code Online (Sandbox Code Playgroud)

以某种方式可能强制弹性接受查询中的转义字符串而不是原始查询?

谢谢.

DrT*_*ech 5

假设你正在使用例如bash,那么你有一个太多的反斜杠:

curl -XGET 'http://localhost:9200/index/type/_search?pretty=1' -d '
    {"query" : {"text" : { "_all" : "\u0159eky" }}}
'
{
  "took" : 16,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.10848885,
    "hits" : [ {
      "_index" : "index",
      "_type" : "type",
      "_id" : "1",
      "_score" : 0.10848885, "_source" : {"name" : "Vrba u ?eky"}
    } ]
  }
}
Run Code Online (Sandbox Code Playgroud)