Limit the result of Elasticsearch query

Hi,

I wrote one elasticsearch query to get only top 10 result in descending order

{ "size": 10, "aggs": { "group_by_user": { "terms": { "field": "user.raw" } } } }

I am getting the following errorResult window is too large, from + size must be less than or equal to: [10000] but was [10250]

How to rephrase my query to get the exact result of what I am looking for it.

Thanks in advance

This is quite odd.

Are you certain the query you provided is the complete and accurate search that received that error?

@Glen_Smith. I am not sure whether my query is perfect enough to satisfy my requirement .

You should place the 'size' param inside the 'group_by_user' instead of outside the 'agg' block, then it will work. Top level size applies to query results, not aggregation results :slight_smile:

{
  "aggs": {
    "group_by_user": {
      "terms": {
        "field": "user.raw",
         "size": 10
      }
    }
  }
}

I am getting the below error,
Result window is too large, from + size must be less than or equal to: [10000] but was [10010]