elasticsearch,date-histogram,Time,Aggregation,elasticsearch,Date Histogram" /> elasticsearch,date-histogram,Time,Aggregation,elasticsearch,Date Histogram" />

Time 带小时间隔的Elasticsearch日期直方图

Time 带小时间隔的Elasticsearch日期直方图,time,aggregation,elasticsearch,date-histogram,Time,Aggregation,elasticsearch,Date Histogram,我正在尝试这样做: "aggs":{ "visits_by_hour":{ "date_histogram":{ "field": "acctstarttime", "interval":"hour", "format": "HH", "min_doc_count": 0 } } } 它工作得很好,但我需要按小时分组,而不是在同一小时内返回多个小时,这

我正在尝试这样做:

"aggs":{
    "visits_by_hour":{
        "date_histogram":{
            "field": "acctstarttime",
            "interval":"hour",
            "format": "HH",
            "min_doc_count": 0
        }
    }
}
它工作得很好,但我需要按小时分组,而不是在同一小时内返回多个小时,这有意义吗?这就是我现在得到的:

{
      "key_as_string": "12",
      "key": 1440244800000,
      "doc_count": 18
},
{
      "key_as_string": "12",
      "key": 1440331200000,
      "doc_count": 17
}
这是我需要的(按小时分组):

建议

编辑

我找到了解决那个问题的办法。不确定这是否是最好的方法,但它是有效的

"aggs": {
    "hour": {
        "terms": {
            "script": "doc['acctstarttime'].date.hourOfDay"
        }
    }
}
"aggs": {
    "hour": {
        "terms": {
            "script": "doc['acctstarttime'].date.hourOfDay"
        }
    }
}