select sum(a) as count , HOUR(FROM_UNIXTIME(create_time)) as h from alert group by h
create_time
类似于此1600506000
。我不知道如何将int转换为时间戳。
最佳答案
考虑 UTC日期的“一天中的时间”。 一种方法可能是。
GET <indexName>/_search
{
"size": 0,
"aggs": {
"NAME": {
"terms": {
"script": {
"source": "Instant.ofEpochMilli(doc['create_time'].value * 1000).atZone(ZoneId.of(\"Z\")).getHour()"
}
},"aggs": {
"NAME": {
"sum": {
"field": "a"
}
}
}
}
}
}
关于elasticsearch - 在Elasticsearch中将int转换为时间戳获取小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63970491/