I written this code to test scroll api. As mentioned in docs the scroll id will change for every request.
But in my case it is same for all requests.
The initial search request and each subsequent scroll request returns a new _scroll_id — only the most recent _scroll_id should be used.
Here is my code sample
from elasticsearch import Elasticsearch
es = Elasticsearch(['10.225.253.130:9200'], sniff_on_start=True)
my_dict = {}
my_dict['query'] = {}
my_dict['query']['match_all'] = {}
result = es.search(index='.monitoring-kibana-2-2017.10.27', body=my_dict, size=1000, scroll="1m")
print result['_scroll_id']
for x in range(10):
result_in_scroll = es.scroll(scroll_id=result['_scroll_id'], scroll="1m")
print result_in_scroll['_scroll_id']
result['_scroll_id'] = result_in_scroll['_scroll_id']
if (len(result_in_scroll['hits']['hits']) == 0):
break
print "Terminated correctly"
This is the output I got
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
DXF1ZXJ5QW5kRmV0Y2gBAAAAAACXzVwWTXZBaGJGOE5UZW1vWGxabjhfM0JnQQ==
Terminated correctly
My scroll is same in all cases. Is this expected behaviour or not???
I am using 5.4.0 ES