我有以下索引
mytestindex
mytesttype
在Elasticsearch 5.5中:
PUT /mytestindex
{
"mappings": {
"mytesttype": {
"_source": {
"enabled": true
},
"_all": {
"enabled": true
},
"properties": {
"Id": {
"type":"text"
},
"RadarId": {
"type":"keyword"
},
"VehicleId": {
"type":"keyword"
},
"Datetime": {
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss.SSS"
},
"Hour": {
"type":"integer"
}
}
}
}
}
我是Elasticsearch的初学者。我想知道是否有可能在11:00到12:00之间获得每小时平均车辆数?我应该使用哪种类型的查询?例如,在MySQL中,我会这样做(简化版,不考虑11:00-12:00):
SELECT AVG( value ), datetime
FROM mytable
GROUP BY HOUR( datetime )
是否可以在Elasticsearch中执行类似的查询?