es date_histogram

{
  "size": 0,
  "aggs": {
    "errors": {
      "date_histogram": {
        "field": "请求时间",
        "interval": "1d",
        "format": "yyyy-MM-dd HH:mm:ss",

   "time_zone":"+08:00",

  "offset":"+6h"
        "min_doc_count": 0,
        "extended_bounds": {
          "min": "2018-08-01 00:00:00",
          "max": "2018-09-30 23:59:59"
        }
      }
    }
  }
}

各字段定义如下

interval:表示时间间隔,可以指定‘year`, `quarter`, `month`, `week`, `day`, `hour`, `minute`, `second`,数字加前面的首字母则可以指定更灵活的时间间隔,其中2个月为2M。2分钟为2m.

format:指定日期格式

time_zone:指定时区

offset:改变时间区间,默认为凌晨0点到午夜24:00

min_doc_count:0表示即使某个时间段内数据为空也还是要返回

原文地址:https://www.cnblogs.com/suntp/p/9636650.html