# Data lose while using scroll

**URL:** <https://discuss.elastic.co/t/data-lose-while-using-scroll/222147>\
**Category:** Elasticsearch\
**Created:** [March 4, 2020, 7:27pm UTC](https://discuss.elastic.co/t/data-lose-while-using-scroll/222147 "2020-03-04T19:27:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [March 4, 2020, 7:27pm UTC](https://discuss.elastic.co/t/data-lose-while-using-scroll/222147/1 "2020-03-04T19:27:34Z")

</div>

Hi I see some data lose while using scroll. I am using the following inside python script.  
Without using scroll it showing the correct number of documents but with scroll I am getting less number of documents.

Any idea about this ?

res = es.search(index=idx,scroll='1m',body=jobqry,timeout='1200s')  
sid = res['\_scroll\_id']  
scroll\_size = res['hits']['total']  
#print(scroll\_size)  
file\_name = new\_dir+"/"+clsname+".txt"  
time.sleep(2)  
cmd\_file = "touch %s" %(file\_name)  
os.system(cmd\_file)  
while (scroll\_size \> 0):  
res=es.scroll(scroll\_id = sid, scroll ='1m')  
sid = res['\_scroll\_id']  
scroll\_size = len(res['hits']['hits'])  
for i in range(0,scroll\_size-1):  
print(res['hits']['hits'][i]['\_source']['id'])

---

<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:** [April 1, 2020, 7:27pm UTC](https://discuss.elastic.co/t/data-lose-while-using-scroll/222147/2 "2020-04-01T19:27:45Z")

</div>

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