# Getting many more results than expected

**URL:** <https://discuss.elastic.co/t/getting-many-more-results-than-expected/345045>\
**Category:** Elasticsearch\
**Created:** [October 15, 2023, 9:03am UTC](https://discuss.elastic.co/t/getting-many-more-results-than-expected/345045 "2023-10-15T09:03:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shlomo\_Koppel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shlomo_koppel/32/126535_2.png) [@Shlomo\_Koppel](https://discuss.elastic.co/u/Shlomo_Koppel)\
**Post date:** [October 15, 2023, 9:03am UTC](https://discuss.elastic.co/t/getting-many-more-results-than-expected/345045/1 "2023-10-15T09:03:47Z")

</div>

Hi,  
I am making the following query:  
`{'bool': {'must': [{'terms': {'doc.attributes.type.keyword': ['Attachment', 'Document']}}, {'terms': {'doc.internal_id': ['xxxx83a1c00f7004b52dxxxx']}}], 'filter': [{'range': {'doc.date_es_index_timestamp': {'lte': 1696569227789}}}]}}`

I am expecting to get a single hit in the results since there is only 1 document with this id. Yet when I run it, it paginates over 100 pages until I get the error:

```auto
java.lang.IllegalArgumentException: Result window is too large, from + size must be less than or equal to: [10000] but was [10100]. 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.

```

The above search appears to be translated to:

```auto
{"from":10000,"size":100,"query":{"bool":{"must":[{"terms":{"doc.attributes.type.keyword":["Attachment","Document"],"boost":1.0}},{"terms":{"doc.internal_id":["xxxx83a1c00f7004b52dxxxx"],"boost":1.0}}],"filter":[{"range":{"doc.date_es_index_timestamp":{"from":null,"to":1696569227789,"include_lower":true,"include_upper":true,"boost":1.0}}}]

```

I am wondering why I would be getting such a large amount of results (over 10000).  
Thank you

---

<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:** [October 15, 2023, 9:48am UTC](https://discuss.elastic.co/t/getting-many-more-results-than-expected/345045/2 "2023-10-15T09:48:54Z")

</div>

Welcome!

How are you running the first query? From which tool or code?

---

<div class="post-metadata">

**Author:** ![Shlomo\_Koppel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shlomo_koppel/32/126535_2.png) [@Shlomo\_Koppel](https://discuss.elastic.co/u/Shlomo_Koppel)\
**Post date:** [October 15, 2023, 10:26am UTC](https://discuss.elastic.co/t/getting-many-more-results-than-expected/345045/3 "2023-10-15T10:26:42Z")

</div>

Thank you!  
I am running using python library elasticsearch\_dsl.  
Our code calling elastic looks like the following:

```auto
       s = Search(using=self._client, index=self._index_pattern).query(query).source([f'doc.{field}' for field in source_fields])
        skip = (page - 1) * size if page > 0 else 0
        s = s[skip:skip + size]
        response = s.execute()

```

---

<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:** [October 15, 2023, 2:04pm UTC](https://discuss.elastic.co/t/getting-many-more-results-than-expected/345045/4 "2023-10-15T14:04:12Z")

</div>

I'm not sure about what you are doing.

Why not using from and size parameters?

[https://elasticsearch-py.readthedocs.io/en/v8.10.1/api.html#elasticsearch.Elasticsearch.search](https://elasticsearch-py.readthedocs.io/en/v8.10.1/api.html#elasticsearch.Elasticsearch.search)

---

<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:** [November 12, 2023, 2:04pm UTC](https://discuss.elastic.co/t/getting-many-more-results-than-expected/345045/5 "2023-11-12T14:04:26Z")

</div>

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