Same results over scrolling in elastic search

#elasticsearch #scroll #completion suggestion
I am getting the same results when scrolling through the results of elastic search when I am using scroll request is giving me the same _scroll_id in response.
I am not getting why I am receiving same set of results.
indent preformatted text by 4 spaces
from elasticsearch import Elasticsearch
es = Elasticsearch([{'host': '#####', 'port': 9200}])
from elasticsearch.helpers import bulk, streaming_bulk
from elasticsearch_dsl import Search
import json
body = {
"suggest": {
"county_suggestion_for_dealer": {
"prefix": "north",
"completion": {
"field": "state",
"size": 10000,
"contexts": {
"dealername": "dealer2"
}
}
}
}
}
data = es.search(
index="autocomplete",
doc_type="panels",
scroll='2m',
body=body
)
scroll_size=len(data['suggest']['county_suggestion_for_dealer'][0]['options'])
options = data['suggest']['county_suggestion_for_dealer'][0]['options']
sid = data['_scroll_id']
states_for_dealer = set()
print(data)

while scroll_size > 0:
data = es.scroll(scroll_id=sid, scroll='2m')
sid = data['_scroll_id']
options=data['suggest']['county_suggestion_for_dealer'][0]['options']
scroll_size=len(options)
print(sid, ",", scroll_size)
for j in range(scroll_size):
states_for_dealer.add(options[j]["_source"]["meid"])
print(options[j]["_source"]["meid"])
indent preformatted text by 4 spaces

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