How to set the limit in for nested aggregations results

How can I set the total result limit for my nested aggregations results. I have looked into the composite aggregations but it gives me error as I am using geo_distance aggregation and composite aggregation doesn't support geo_distance aggregations

My Code:

{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "should": [
              {
                "nested": {
                  ....
                  ....
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        },
        {
          "bool": {
            "should": [
              {
                "nested": {
                  ....
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ]
    }
  },
  "aggs": {
    "geoDistance": {
      "geo_distance": {
        "field": "location",
        ...
        ...
      },
      "aggs": {
        "dayRange": {
          "date_histogram": {
            ...
            ...
          },
          "aggs": {
                "top_users": {
                  "top_hits": {
                    "sort": [
                      {
                        "score": {
                          "order": "desc"
                        }
                      }
                    ],
                    "size": 15
                  }
                }
              }
        }
      }
    }
  }
}

Here I have set the size 15 but I guess it set the limit in every buckets results and what I whats to achieves is that total doc_count limit should be 15.

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