# Scroll in Python Elasticsearch client is not working

**URL:** <https://discuss.elastic.co/t/scroll-in-python-elasticsearch-client-is-not-working/317038>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 19, 2022, 5:28pm UTC](https://discuss.elastic.co/t/scroll-in-python-elasticsearch-client-is-not-working/317038 "2022-10-19T17:28:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yeashin\_Rabbi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeashin_rabbi/32/104451_2.png) [@Yeashin\_Rabbi](https://discuss.elastic.co/u/Yeashin_Rabbi)\
**Post date:** [October 19, 2022, 5:28pm UTC](https://discuss.elastic.co/t/scroll-in-python-elasticsearch-client-is-not-working/317038/1 "2022-10-19T17:28:41Z")

</div>

I tried to scroll all documents with python. it return empty array of hits. Here is my code:

```
     es = Elasticsearch(self.source, http_auth=(self.user, self.password),
                       timeout=80000, request_timeout=30000, max_retries=5,
                       retry_on_timeout=True, verify_certs=False)
    print(self.Index)
    pg = es.search(index=self.Index, scroll='5m', body=self.query, size=10000)
    print(pg)
    sid = pg['_scroll_id']

    while True:
        pg = es.scroll(scroll_id=sid, scroll='1m')
        print(pg)
        # Update the scroll ID
        sid = pg['_scroll_id']
        # Get the number of results that we returned in the last scroll
        scroll_size = len(pg['hits']['hits'])

```

when I print out pg after search I can see list of hits. However, after scroll when I print out pg , the array of hits is empty.

---

<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 16, 2022, 5:29pm UTC](https://discuss.elastic.co/t/scroll-in-python-elasticsearch-client-is-not-working/317038/2 "2022-11-16T17:29:00Z")

</div>

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