Elasticsearch search_phase_execution_exception in Python

I fetch all my Elasticsearch documents via using scroll api with below code in Python.

size = 100
data = es.search(
            index=index,
            scroll='25m',
            size=size,
            body=body
        )
max_val = data['hits']['total']['value']

sid = data['_scroll_id']
scroll_size = len(data['hits']['hits'])
while scroll_size > 0:
    .........
    data = es.scroll(scroll_id=sid, scroll='25m')
    sid = data['_scroll_id']
    scroll_size = len(data['hits']['hits'])

In some index I have less then 100 documents and some of them I have more than 30000 documents thats why I use scroll api.

I've written this code via this tutorial

The code works, but after some time, I get the below error.

NotFoundError(404, 'search_phase_execution_exception', 'No search context found for id

I tried to solve this error with changing scroll. The scroll was 5m and then I set 25m but still get same error. How can i solve this?

Thanks for answering

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