统计总数:
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"
}
}
}
}
}
}
标签:01,聚合,aggs,09,field,分组,2022,ElasticSearch,size
From: https://www.cnblogs.com/s0611163/p/16650605.html