通过给定范围的属性查询 elasticsearch 索引?

Query an elasticsearch index by an attribute, with a given range?

我想查询我的索引,以便它在出现名为站点名称的特定属性时匹配,但我想要特定时间范围内的所有数据。我认为可能是以下内容但不确定:

  {
      "query": {
        "range": {
          "timestamp": {
            "gte": "now-1h/h",
            "lt": "now/h"
          }
        },
        "match": {"sitename" : "HARB00ZAF0" } 
      }
  }

你快到了,但你需要利用 bool queries

{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "timestamp": {
              "gte": "now-1h/h",
              "lt": "now/h"
            }
          }
        }
      ],
      "must": [
        {
          "match": {
            "sitename": "HARB00ZAF0"
          }
        }
      ]
    }
  }
}