Check successful shards instead of failed

Fixes #660, thanks @juke1
This commit is contained in:
Honza Král
2017-11-09 20:35:53 +01:00
parent 32239539f9
commit 92763522a9
+5 -5
View File
@@ -375,16 +375,16 @@ def scan(client, query=None, scroll='5m', raise_on_error=True,
yield hit yield hit
# check if we have any errrors # check if we have any errrors
if resp["_shards"]["failed"]: if resp["_shards"]["successful"] < resp["_shards"]["total"]:
logger.warning( logger.warning(
'Scroll request has failed on %d shards out of %d.', 'Scroll request has only succeeded on %d shards out of %d.',
resp['_shards']['failed'], resp['_shards']['total'] resp['_shards']['successful'], resp['_shards']['total']
) )
if raise_on_error: if raise_on_error:
raise ScanError( raise ScanError(
scroll_id, scroll_id,
'Scroll request has failed on %d shards out of %d.' % 'Scroll request has only succeeded on %d shards out of %d.' %
(resp['_shards']['failed'], resp['_shards']['total']) (resp['_shards']['successful'], resp['_shards']['total'])
) )
scroll_id = resp.get('_scroll_id') scroll_id = resp.get('_scroll_id')