# Same results over scrolling in elastic search

**URL:** <https://discuss.elastic.co/t/same-results-over-scrolling-in-elastic-search/180349>\
**Category:** Elasticsearch\
**Created:** [May 9, 2019, 11:40am UTC](https://discuss.elastic.co/t/same-results-over-scrolling-in-elastic-search/180349 "2019-05-09T11:40:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarunnar](https://avatars.discourse-cdn.com/v4/letter/t/a6a055/32.png) [@tarunnar](https://discuss.elastic.co/u/tarunnar)\
**Post date:** [May 9, 2019, 11:40am UTC](https://discuss.elastic.co/t/same-results-over-scrolling-in-elastic-search/180349/1 "2019-05-09T11:40:21Z")

</div>

#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

---

<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:** [June 6, 2019, 11:40am UTC](https://discuss.elastic.co/t/same-results-over-scrolling-in-elastic-search/180349/2 "2019-06-06T11:40:23Z")

</div>

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