簡體   English   中英

彈性搜索多條件查詢

[英]Elastic search multi condition query

我是彈性搜索的新手,並嘗試使用以下條件查詢我的存儲日志:返回上一小時的所有“致命”級別字段。 這是我運行的最后一個返回錯誤的代碼:

    GET /eu-multitenant*/_search
{
  "query": 
  { "bool": {
    "should": [
        "match": {"level": "fatal" },
        "range": {"@timestamp": {"gte": "now-1h"}}
      ]
  }

  },
  "_source": ["d.Message","@timestamp"],
  "sort": { "@timestamp" : {"order" : "desc"}},
  "size": 100
}    

這是錯誤:

  "error": {
    "root_cause": [
      {
        "type": "json_parse_exception",
        "reason": "Unexpected character (':' (code 58)): was expecting comma to separate Array entries\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@4be698a; line: 5, column: 17]"
      }
    ],

感謝您的幫助。

從發布問題中找到了一些啟發並找到了我的錯誤。 我沒有使用{}包圍不同的查詢條件。

GET /eu-multitenant*/_search
{
  "query": 
  { "bool": {
    "must": [
        {"match": {"level": "fatal" }},
        {"range": {"@timestamp": {"gte": "now-24h"}}}
      ]
  }

  },
  "_source": ["d.Message","@timestamp"],
  "sort": { "@timestamp" : {"order" : "desc"}},
  "size": 100
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM