Elastic: Filtering data after grouping

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"
                }
              }
            ]
          }
        }
      }
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.