将ES中long类型的日期时间戳转为日期格式进行分组统计。
{ "size": 0, "query": { "bool": { "must": [ { "range": { "crawltime": { "from": 1730706212000, "to": 1733298205474, "include_lower": false, "include_upper": true, "boost": 1 } } } ] } }, "aggs": { "sss": { "terms": { "script": { "source": "DateTimeFormatter df = DateTimeFormatter.ofPattern(\"yyyy-MM-dd\").withZone(ZoneId.systemDefault()); return df.format(Instant.ofEpochMilli(doc['crawltime'].value));", "lang": "painless" }, "order": { "_key": "asc" } } } } }
标签:long,日期,分组,格式,ES,crawltime From: https://www.cnblogs.com/commissar-Xia/p/18588198