1、分组按日期聚合
POST api_visit_logs/_search
{
"query": {
"bool": {
"must": [{
"range": {
"json.timestamp": {
"gte": "2023-06-28",
"lte": "2023-06-30"
}
}
}]
}
},
"aggs": {
"studyCount": {
"date_histogram": {
"field": "json.timestamp",
"interval": "1d",
"time_zone": "+08:00",
"format":"yyyy/MM/dd"
}
}
}
}
2、分组按关键字聚合
POST api_visit_logs/_search
{
"query": {
"bool": {
"must": [{
"range": {
"json.timestamp": {
"gte": "2023-06-28",
"lte": "2023-06-30"
}
}
}]
}
},
"aggs" : {
"count" : { "terms" : { "field" : "json.http_uuid" } }
}
}