# "Result window is too large" http response depends on the presence of the sort field

**URL:** <https://discuss.elastic.co/t/result-window-is-too-large-http-response-depends-on-the-presence-of-the-sort-field/284738>\
**Category:** Elasticsearch\
**Created:** [September 21, 2021, 2:41pm UTC](https://discuss.elastic.co/t/result-window-is-too-large-http-response-depends-on-the-presence-of-the-sort-field/284738 "2021-09-21T14:41:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![franck.valentin](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@franck.valentin](https://discuss.elastic.co/u/franck.valentin)\
**Post date:** [September 21, 2021, 2:41pm UTC](https://discuss.elastic.co/t/result-window-is-too-large-http-response-depends-on-the-presence-of-the-sort-field/284738/1 "2021-09-21T14:41:11Z")

</div>

Hi,

I'm facing a strange behaviour on Elasticsearch 7.7 when I perform a search on several indexes and the result window is too large.  
If the query is:

```auto
GET /_search
{
  "size": 500,
  "from": 10000,
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "stop": {
              "gte": "2021-01-01T11:40:00Z"
            }
          }
        },
        {
          "range": {
            "start": {
              "lte": "2021-04-01T11:40:00Z"
            }
          }
        }
      ]
    }
  }
}

```

then the response code is **400** , with

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Result window is too large, from + size must be less than or equal to: [10000] but was [10500]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."
      },
[...]

```

But if the query contains a sort field:

```auto
GET /_search
{
  "size": 500,
  "from": 10000,
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "stop": {
              "gte": "2021-01-01T11:40:00Z"
            }
          }
        },
        {
          "range": {
            "start": {
              "lte": "2021-04-01T11:40:00Z"
            }
          }
        }
      ]
    }
  },
  "sort": [
    {
      "start": {
        "order": "desc",
        "missing": "_first"
      }
    }
  ]
}	

```

then the response code is **200** with

```auto
{
  "took" : 112,
  "timed_out" : false,
  "_shards" : {
    "total" : 28,
    "successful" : 19,
    "skipped" : 19,
    "failed" : 9,
    "failures" : [
      {
        "shard" : 0,
        "index" : "my-index-1",
        "node" : "gIeCOD9jQxyVUQUahxmIXg",
        "reason" : {
          "type" : "illegal_argument_exception",
          "reason" : "Result window is too large, from + size must be less than or equal to: [10000] but was [10500]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."
        }
      },
      {
[...]

```

Is it normal? Should the response codes be the same?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 21, 2021, 3:45pm UTC](https://discuss.elastic.co/t/result-window-is-too-large-http-response-depends-on-the-presence-of-the-sort-field/284738/2 "2021-09-21T15:45:16Z")

</div>

It looks like a bug to me. Could you try to reproduce it on 7.14.1 and if you can open an issue in GitHub?

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [September 21, 2021, 5:14pm UTC](https://discuss.elastic.co/t/result-window-is-too-large-http-response-depends-on-the-presence-of-the-sort-field/284738/3 "2021-09-21T17:14:04Z")

</div>

I just tested in `7.14.1` and it gives a `"status" : 400` so it must have been fixed at some point.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 19, 2021, 5:14pm UTC](https://discuss.elastic.co/t/result-window-is-too-large-http-response-depends-on-the-presence-of-the-sort-field/284738/4 "2021-10-19T17:14:39Z")

</div>

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