diff --git a/elasticsearch/helpers.py b/elasticsearch/helpers.py index 94539f2d..f8ef2976 100644 --- a/elasticsearch/helpers.py +++ b/elasticsearch/helpers.py @@ -1,4 +1,4 @@ -from itertools import islice, chain +from itertools import islice from operator import methodcaller try: from itertools import imap as map @@ -106,7 +106,7 @@ def streaming_bulk(client, actions, chunk_size=500, raise_on_error=False, expand resp = client.bulk(bulk_actions, **kwargs) # go through request-reponse pairs and detect failures - for op_type, item in chain.from_iterable(map(methodcaller('items'), resp['items'])): + for op_type, item in map(methodcaller('popitem'), resp['items']): ok = item.get('ok') if not ok and raise_on_error: errors.append({op_type: item})