# Max Window Size is Set to 10000 but the Terms aggregations is giving single filter value larger than max window size.

**URL:** <https://discuss.elastic.co/t/max-window-size-is-set-to-10000-but-the-terms-aggregations-is-giving-single-filter-value-larger-than-max-window-size/348924>\
**Category:** Elasticsearch\
**Created:** [December 8, 2023, 4:33pm UTC](https://discuss.elastic.co/t/max-window-size-is-set-to-10000-but-the-terms-aggregations-is-giving-single-filter-value-larger-than-max-window-size/348924 "2023-12-08T16:33:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![yago82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yago82/32/97755_2.png) [@yago82](https://discuss.elastic.co/u/yago82)\
**Post date:** [December 9, 2023, 3:50pm UTC](https://discuss.elastic.co/t/max-window-size-is-set-to-10000-but-the-terms-aggregations-is-giving-single-filter-value-larger-than-max-window-size/348924/2 "2023-12-09T15:50:46Z")

</div>

Hi,

Yes, you can limit your search results to the top 10,000 records. This is actually the default limit in Elasticsearch for a single query. If you need to retrieve more than 10,000 results, you would typically use the Scroll or Search After API, but in your case, it sounds like you want to avoid this due to performance concerns.

Here's an example of how you can limit your search results:

```auto
GET /your_index/_search
{
  "query": {
    "match": {
      "title": "doctor"
    }
  },
  "size": 10000
}

```

This will return the top 10,000 matches for "doctor" in the title field.

As for your questions about filtering and sorting, yes, you can apply filters and sorting to these 10,000 records. The filters and sorting will be applied at query time, so they will only affect the top 10,000 records that match your query.

Here's an example of how you can apply a filter and sort your results:

```auto
GET /your_index/_search
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "title": "doctor"
        }
      },
      "filter": {
        "term": {
          "some_field": "some_value"
        }
      }
    }
  },
  "sort": [
    { "another_field": "asc" }
  ],
  "size": 10000
}

```

This will return the top 10,000 matches for "doctor" in the title field, that also have "some\_value" in "some\_field", sorted by "another\_field" in ascending order.

---

_[View the full topic](https://discuss.elastic.co/t/max-window-size-is-set-to-10000-but-the-terms-aggregations-is-giving-single-filter-value-larger-than-max-window-size/348924)._
