From 92763522a9f5937f2af92ad10f1c190c40b76500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Kr=C3=A1l?= Date: Thu, 9 Nov 2017 20:34:47 +0100 Subject: [PATCH] Check successful shards instead of failed Fixes #660, thanks @juke1 --- elasticsearch/helpers/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/elasticsearch/helpers/__init__.py b/elasticsearch/helpers/__init__.py index a59437da..223a0ca0 100644 --- a/elasticsearch/helpers/__init__.py +++ b/elasticsearch/helpers/__init__.py @@ -375,16 +375,16 @@ def scan(client, query=None, scroll='5m', raise_on_error=True, yield hit # check if we have any errrors - if resp["_shards"]["failed"]: + if resp["_shards"]["successful"] < resp["_shards"]["total"]: logger.warning( - 'Scroll request has failed on %d shards out of %d.', - resp['_shards']['failed'], resp['_shards']['total'] + 'Scroll request has only succeeded on %d shards out of %d.', + resp['_shards']['successful'], resp['_shards']['total'] ) if raise_on_error: raise ScanError( scroll_id, - 'Scroll request has failed on %d shards out of %d.' % - (resp['_shards']['failed'], resp['_shards']['total']) + 'Scroll request has only succeeded on %d shards out of %d.' % + (resp['_shards']['successful'], resp['_shards']['total']) ) scroll_id = resp.get('_scroll_id')