2016-06-20 54 views
0

ElasticSearch返回我“query_parsing_exception”,“原因”:“[布尔]查询不支持”尝试使用查找条目时错误以下query.i认为这个问题是关于“QUERY_STRING”elasticsearch查询不支持query_string?

curl -XGET '<myurl>:<myport>/index/_search?pretty' -d ' 
{ 
    "query": { 
    "bool": { 
     "must":[ { 
      "term" : { 
       "query" : "1.2.3.4", 
       "fields" : [ "ip" ] 
        } 
       },{ 
       "range" : { 
       "localtime" : { 
        "from" : "2016-06-15T06:00:04.923Z", 
        "to" : "2016-06-17T17:43:04.923Z", 
        "include_lower" : true, 
        "include_upper" : true 
           } 
         } 
       }, 
      "query_string" : { 
      "default_field" : "_all", 
      "query" : "word1 OR word1", 

      } ] 
     } 
    } 
}' 

为什么会出现此错误?

感谢


anyhelp可以理解的!谢谢!

回答

3

它通常有助于适当地格式化您的查询。在你的情况下,你在query_string之前缺少一个大括号,并且你的query_string查询后有一个逗号过多。

Reformating像这样将工作:

curl -XGET '<myurl>:<myport>/index/_search?pretty' -d ' 
{ 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "term": { 
      "ip": "1.2.3.4" 
      } 
     }, 
     { 
      "range": { 
      "localtime": { 
       "from": "2016-06-15T06:00:04.923Z", 
       "to": "2016-06-17T17:43:04.923Z", 
       "include_lower": true, 
       "include_upper": true 
      } 
      } 
     }, 
     { 
      "query_string": { 
      "default_field": "_all", 
      "query": "word1 OR word1" 
      } 
     } 
     ] 
    } 
    } 
}' 
+0

得到了错误信息:“理由”:“[术语]查询不支持值数组”, –

+0

我已经更新了我的答案。 – Val

+0

Val,你会帮我解决问题吗?http://stackoverflow.com/questions/37925507/elasticsearch-how-to-get-distinct-value-from-two-indeices-in-php-client –