# Python API for Elastic Search - Getting 10000 in response every time

**URL:** <https://discuss.elastic.co/t/python-api-for-elastic-search-getting-10000-in-response-every-time/213209>\
**Category:** Elasticsearch\
**Created:** [December 27, 2019, 3:54pm UTC](https://discuss.elastic.co/t/python-api-for-elastic-search-getting-10000-in-response-every-time/213209 "2019-12-27T15:54:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayanth5](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@jayanth5](https://discuss.elastic.co/u/jayanth5)\
**Post date:** [December 27, 2019, 3:54pm UTC](https://discuss.elastic.co/t/python-api-for-elastic-search-getting-10000-in-response-every-time/213209/1 "2019-12-27T15:54:06Z")

</div>

```
client = Elasticsearch([host1, host2], http_auth=(user, password), scheme="http", port=port)
response = client.search(index="complats*", body={"from": 0, "size": 10000, "query": {
            "bool": {
                "must": [
                    {
                        "query_string": {
                            "query": "tags:\"prod\" AND severity:\"INFO\" AND service:\"abc-service\" AND msg:\"* is processed\"",
                            "fields": [],
                            "type": "best_fields",
                            "default_operator": "or",
                            "max_determinized_states": 10000,
                            "enable_position_increments": "true",
                            "fuzziness": "AUTO",
                            "fuzzy_prefix_length": 0,
                            "fuzzy_max_expansions": 50,
                            "phrase_slop": 0,
                            "escape": "false",
                            "auto_generate_synonyms_phrase_query": "true",
                            "fuzzy_transpositions": "true",
                            "boost": 1.0
                        }
                    },
                    {
                        "range": {
                            "@timestamp": {
                                "from": "now-{}s".format((now.minute + 1) * 60),
                                "to": "now",
                                "include_lower": "true",
                                "include_upper": "true",
                                "boost": 1.0
                            }
                        }
                    }
                ],
                "adjust_pure_negative": "true",
                "boost": 1.0
            }
        }})
value = response['hits']['total']['value']
print(value)

```

The above query is successfully connecting to elasticsearch but returning an incorrect value or 10000 every time. What could be wrong here? I've read somewhere that elasticsearch module in python has a bug where it maxes out at 10000. Changing "max\_determinized\_states": 10000 isn't helping and it is still returning the same value. Anyone else faced this problem? If yes how did u resolve it? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)\
**Post date:** [December 27, 2019, 5:12pm UTC](https://discuss.elastic.co/t/python-api-for-elastic-search-getting-10000-in-response-every-time/213209/2 "2019-12-27T17:12:16Z")

</div>

If you have more results then the search size (you have set it to 10000) you need to scroll over the result set.

[Here is an example.](https://gist.github.com/hmldd/44d12d3a61a8d8077a3091c4ff7b9307)

---

<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:** [January 24, 2020, 5:12pm UTC](https://discuss.elastic.co/t/python-api-for-elastic-search-getting-10000-in-response-every-time/213209/3 "2020-01-24T17:12:21Z")

</div>

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