# Elasticsearch dsl (python) scanerror

**URL:** <https://discuss.elastic.co/t/elasticsearch-dsl-python-scanerror/201980>\
**Category:** Elasticsearch\
**Created:** [October 2, 2019, 2:49pm UTC](https://discuss.elastic.co/t/elasticsearch-dsl-python-scanerror/201980 "2019-10-02T14:49:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![duttad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/duttad/32/72269_2.png) [@duttad](https://discuss.elastic.co/u/duttad)\
**Post date:** [October 2, 2019, 2:49pm UTC](https://discuss.elastic.co/t/elasticsearch-dsl-python-scanerror/201980/1 "2019-10-02T14:49:46Z")

</div>

I am getting the following error while trying to scroll through results:  
elasticsearch.helpers.ScanError: Scroll request has only succeeded on 13 shards out of 14

The code looks like this:

```python
from elasticsearch_dsl import Search # pip install elasticsearch-dsl
s = Search(using = es, index = <index-name>, doc_type = '_doc').query("match", <field-name>=<name-string>).query("range", **{'@timestamp': {'gte': 'now-30d', 'lt': 'now'}} )
hits = s.scan()
log_list = []
for hit in hits:
    log = vars(hit)['_d_']
    #print( log )        
    log_list.append( log )

```

I am wondering what might cause this issue. Is there something wrong with the 1 shard, or the server containing the shard? Thought I would ask before digging in too deep in case someone has encountered and solved it already. I found the following question in the forum, but no answer.

> [@Elasticsearch DSL Scroll error](https://discuss.elastic.co/t/elasticsearch-dsl-scroll-error/167253):
>
> I am using this code below and it gives me the following error. from elasticsearch import Elasticsearch, helpers from elasticsearch\_dsl import Search es = Elasticsearch('elasticsearch', port=9200) s = Search(using=es, index="metricinfo\*").query("match", \*\*{"mid.keyword": self.mid}).filter('range', \*\*{"@timestamp":{'gte': 'now-7d' , 'lt': 'now'}}) s=s.extra(\_source={"includes":['@timestamp','value','mid']}) s.execute() for hit in s.scan(): print(hit['value']) Scroll r…

---

<div class="post-metadata">

**Author:** ![honzakral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honzakral/32/44958_2.png) [@honzakral](https://discuss.elastic.co/u/honzakral)\
**Post date:** [October 4, 2019, 9:48am UTC](https://discuss.elastic.co/t/elasticsearch-dsl-python-scanerror/201980/2 "2019-10-04T09:48:06Z")

</div>

This is most likely a bug where we don't take into account shards that have been `skipped`, those should be counted as successful but the code doesn't reflect that. My apologies for this, I just pushed a fix for this into `elasticsearch-py` and will do a release soon - [https://github.com/elastic/elasticsearch-py/commit/fc78c992ef6ceca157f369186760c8c550fb3bc4](https://github.com/elastic/elasticsearch-py/commit/fc78c992ef6ceca157f369186760c8c550fb3bc4)

---

<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:** [November 1, 2019, 9:48am UTC](https://discuss.elastic.co/t/elasticsearch-dsl-python-scanerror/201980/3 "2019-11-01T09:48:06Z")

</div>

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