First aggregate according to the people, then count the data in each group, and filter out the people whose start time field is > minimum time - 10 days and whose start time is < minimum time + 10 days
Is this all right, please
GET /users_index/_search
{
"size": 0,
"aggs": {
"aggs": {
"terms": {
"field": "userId"
},
"aggs": {
"minTime":{
"min": {
"field": "updateTime"
}
},
"top": {
"top_hits": {
"size": 10,
"sort": [
{
"updateTime": {
"order": "desc"
}
}
]
}
}
}
}
}
}