# Elastic search time out error frequently when we do 'mget' operation for bulk records

**URL:** <https://discuss.elastic.co/t/elastic-search-time-out-error-frequently-when-we-do-mget-operation-for-bulk-records/166512>\
**Category:** Elasticsearch\
**Created:** [January 31, 2019, 9:45am UTC](https://discuss.elastic.co/t/elastic-search-time-out-error-frequently-when-we-do-mget-operation-for-bulk-records/166512 "2019-01-31T09:45:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinodanumarla](https://avatars.discourse-cdn.com/v4/letter/v/a698b9/32.png) [@vinodanumarla](https://discuss.elastic.co/u/vinodanumarla)\
**Post date:** [January 31, 2019, 9:45am UTC](https://discuss.elastic.co/t/elastic-search-time-out-error-frequently-when-we-do-mget-operation-for-bulk-records/166512/1 "2019-01-31T09:45:59Z")

</div>

I have written python code to get the data from elasticsearch using 'mget' function, but soon after my index count is reached to 360k docs, I'm getting elasticsearch timeout error frequently though I keep request\_timeout=100, 200....,  
Here is the script which I am using to fetch the documents from elasticsearch

ID =['id1', 'id2', 'id3', 'id4', ..............'id2500']  
es.mget(index=indexname, doc\_type=doctype, body={'ids': ID }, request\_timeout=100)

As a workaround I did the following :  
Since I am trying to fetch 25K records through mget which is getting timed out. So I reduce the amount of data to be fetched for example, fetching 5K records. It's working fine, but it is hitting my script performance ....

Can anyone please help me out to get out of this error.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 31, 2019, 9:53am UTC](https://discuss.elastic.co/t/elastic-search-time-out-error-frequently-when-we-do-mget-operation-for-bulk-records/166512/2 "2019-01-31T09:53:17Z")

</div>

You may want to look at using [https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-request-scroll.html) instead.

---

<div class="post-metadata">

**Author:** ![vinodanumarla](https://avatars.discourse-cdn.com/v4/letter/v/a698b9/32.png) [@vinodanumarla](https://discuss.elastic.co/u/vinodanumarla)\
**Post date:** [January 31, 2019, 12:08pm UTC](https://discuss.elastic.co/t/elastic-search-time-out-error-frequently-when-we-do-mget-operation-for-bulk-records/166512/3 "2019-01-31T12:08:59Z")

</div>

mget function doesn't supports the scroll and all. Do we have any best way to handle with mget since my lot of python code depends on output of of mget, I can't change the mget.

Thanks.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 2, 2019, 2:35am UTC](https://discuss.elastic.co/t/elastic-search-time-out-error-frequently-when-we-do-mget-operation-for-bulk-records/166512/4 "2019-02-02T02:35:38Z")

</div>

mget is not meant for this type of use case, scroll is.

---

<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:** [March 2, 2019, 2:35am UTC](https://discuss.elastic.co/t/elastic-search-time-out-error-frequently-when-we-do-mget-operation-for-bulk-records/166512/5 "2019-03-02T02:35:41Z")

</div>

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