2016-06-20 81 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 –

相關問題