ElasticSearch 分组聚合统计
统计总数:
GET mytest-statistics/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"range": {
"day": {
"gte": "2022-09-01",
"lte": "2022-09-01"
}
}
}
]
}
},
"aggs": {
"sumAggCount": {
"sum": {
"field": "count"
}
}
}
}
``
分组聚合统计:
```json
GET mytest-statistics/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"range": {
"day": {
"gte": "2022-09-01",
"lte": "2022-09-01"
}
}
}
]
}
},
"aggs": {
"sumByCameraId": {
"terms": {
"field": "cameraId",
"size": 100000000
},
"aggs": {
"sumAggCount": {
"sum": {
"field": "count"
}
}
}
}
}
}