2016-06-08 98 views
1

我已經查看了StackOverflow和Elastic站點上的其他示例,但我無法使此組合Elasticsearch查詢生效。Elasticsearch合併查詢

個別項目名稱和時間戳的查詢工作,但不是這個組合查詢:

curl -XGET "http://localhost/jenkins/_search/exists" -d'{"query" : {"bool": {"must": [{"match": {"data.projectName": {"query": "QA_Deployment","type": "phrase"}}}]},{"range": {"@timestamp": {"gte": "now-30d","lte": "now"}}}}}' 

回答

1

我改變了兩件事情,又出現了-d」,不知道這是一個問題,但缺少之間的空間。另一件事是第二個查詢。這也應該在bool> must部分中。這應該工作:

curl -XGET "http://localhost/jenkins/_search/exists" -d ' 
{ 
    "query" : { 
     "bool": { 
      "must": [ 
       { 
        "match": { 
         "data.projectName": { 
          "query": "QA_Deployment", 
          "type": "phrase" 
         } 
        } 
       }, 
       { 
        "range": { 
         "@timestamp": { 
          "gte": "now-30d", 
          "lte": "now" 
         } 
        } 
       } 
      ] 
     } 
    } 
}' 
+0

謝謝@Jettro Coenradie,我的布爾格式很糟糕,你已經糾正它。我不能upvote你的答案,但我會,如果我可以:) –

+0

你應該能夠接受答案。 –