Skip to content

Commit c7450b4

Browse files
committed
including original document in case where an error is not raised but returned individually
1 parent 45db46c commit c7450b4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

elasticsearch/helpers/actions.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,17 @@ def _process_bulk_chunk(
143143
bulk_data, map(methodcaller("popitem"), resp["items"])
144144
):
145145
ok = 200 <= item.get("status", 500) < 300
146-
if not ok and raise_on_error:
146+
if not ok:
147147
# include original document source
148-
if len(data) > 1:
148+
if op_type != "delete":
149149
item["data"] = data[1]
150-
errors.append({op_type: item})
151-
152-
if ok or not errors:
153-
# if we are not just recording all errors to be able to raise
154-
# them all at once, yield items individually
150+
if raise_on_error:
151+
errors.append({op_type: item})
152+
else:
153+
# if we are not just recording all errors to be able to raise
154+
# them all at once, yield items individually
155+
yield ok, {op_type: item}
156+
else:
155157
yield ok, {op_type: item}
156158

157159
if errors:

0 commit comments

Comments
 (0)