From af65f556f3414889fb49eec56795a99f00f5d545 Mon Sep 17 00:00:00 2001 From: Kunihiko Kido Date: Wed, 3 Jun 2015 12:07:01 +0900 Subject: [PATCH] Update bulk_index method --- Lib/elasticsearch/helpers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/elasticsearch/helpers.py b/Lib/elasticsearch/helpers.py index 56f9ab4..275fe5a 100644 --- a/Lib/elasticsearch/helpers.py +++ b/Lib/elasticsearch/helpers.py @@ -46,6 +46,10 @@ def bulk_index(client, docs, chunk_size=500, **kwargs): body = "\n".join(bulk_actions) + "\n" response = client.bulk(body, **kwargs) + if 'items' not in response: + errors.append(response) + return success, errors + for op_type, item in map(methodcaller('popitem'), response['items']): ok = 200 <= item.get('status', 500) < 300 if not ok: