Elastic Search 查询时按日期时间字段分组

问题描述 投票:0回答:0

我需要在查询中按天分组,所以我尝试使用日期时间字段应用分组,如下所示:

{
    "_source": "false",
    "query": {
        "match_all": {}
    },
    "aggs": {
        "group_by_weekday": {
            "date_histogram": {
                "field": "record_created_at",
                "calendar_interval": "day",
                "format": "EEEE"
            }
        }
    }
}

但是我得到的结果如下?

{
  "aggregations": {
    "group_by_weekday": {
      "buckets": [
        {
          "key_as_string": "Tuesday",
          "key": 1682380800000,
          "doc_count": 13
        },
        {
          "key_as_string": "Wednesday",
          "key": 1682467200000,
          "doc_count": 0
        },
        {
          "key_as_string": "Thursday",
          "key": 1682553600000,
          "doc_count": 1
        },
        {
          "key_as_string": "Wednesday",
          "key": 1683072000000,
          "doc_count": 1
        },
        {
          "key_as_string": "Thursday",
          "key": 1683158400000,
          "doc_count": 1
        }
      ]
    }
  }
}

这里似乎没有应用分组

我们怎样才能用其他方法来克服这个问题?

elasticsearch full-text-search opensearch
© www.soinside.com 2019 - 2024. All rights reserved.