小编Min*_*cer的帖子

Elasticsearch - 按星期和小时分组

例如,我需要按星期和小时分组获取一些数据

curl -XGET http://localhost:9200/testing/hello/_search?pretty=true -d '
{
        "size": 0,
        "aggs": {
          "articles_over_time" : {
            "date_histogram" : {
                "field" : "date",
                "interval" : "hour",
                "format": "E - k"
            }
          }
        }
}
'
Run Code Online (Sandbox Code Playgroud)

给我这个:

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 2857,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "aggregations" : {
    "articles_over_time" : {
      "buckets" : [ {
        "key_as_string" : "Fri …
Run Code Online (Sandbox Code Playgroud)

aggregation elasticsearch

5
推荐指数
1
解决办法
5771
查看次数

标签 统计

aggregation ×1

elasticsearch ×1