Scroll in Python Elasticsearch client is not working

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.

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