Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 如何在elasticsearch中使用冒号搜索模式?_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch 如何在elasticsearch中使用冒号搜索模式?,elasticsearch,elasticsearch" /> elasticsearch 如何在elasticsearch中使用冒号搜索模式?,elasticsearch,elasticsearch" />

elasticsearch 如何在elasticsearch中使用冒号搜索模式?

elasticsearch 如何在elasticsearch中使用冒号搜索模式?,elasticsearch,elasticsearch,我在Elasticsearch中有一个字段,其值为“ft:05/08/2015 13:01:27.358,cgn:4189”。 当我想用查询字符串“cgn:4189”搜索时,我没有结果。 我试图像“cgn:4189”一样转义冒号,但我有一个语法错误。 我不知道怎么做 {"query":{"bool":{"must":[{"query_string":{"default_field":"fluentd.message","query":"cgn:"}}],"must_not":[],"should

我在Elasticsearch中有一个字段,其值为“ft:05/08/2015 13:01:27.358,cgn:4189”。 当我想用查询字符串“cgn:4189”搜索时,我没有结果。 我试图像“cgn:4189”一样转义冒号,但我有一个语法错误。 我不知道怎么做

{"query":{"bool":{"must":[{"query_string":{"default_field":"fluentd.message","query":"cgn:"}}],"must_not":[],"should":[]}},"from":0,"size":10,"sort":[],"facets":{}}
结果:

"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures
JSON.parse: bad escaped character at line 1 column 91 of the JSON data

结果:

"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures
JSON.parse: bad escaped character at line 1 column 91 of the JSON data

您能帮我吗?

试试这个查询,看看它是否适合您:

{
   "query": {
      "bool": {
         "must": [
            {
               "query_string": {
                  "default_field": "fluentd.message",
                  "query": "cgn\\:4189"
               }
            }
         ],
         "must_not": [],
         "should": []
      }
   },
   "from": 0,
   "size": 10,
   "sort": [],
   "facets": {}
}
下面是我用来测试它的一些感觉代码:

如果这对您不起作用,那么它可能与您的映射和/或分析设置有关。因此,如果您可以在您的问题中发布您的映射,包括任何自定义分析器,它将有所帮助。此外,正确设置代码块的格式将使它们更易于阅读。

引用时,只需在查询中添加转义双引号即可:

{
  "query": {
    "query_string" : {
      "query": "ip_addr:\"2001:db8::/48\""
    }
  }
}

伟大的非常感谢。