Merge pull request #1062 from thomasthiebaud/fix-issue-1020
Support both deprecated and new bulk parameters
This commit is contained in:
@@ -27,22 +27,26 @@ def expand_action(data):
|
|||||||
op_type = data.pop("_op_type", "index")
|
op_type = data.pop("_op_type", "index")
|
||||||
action = {op_type: {}}
|
action = {op_type: {}}
|
||||||
for key in (
|
for key in (
|
||||||
|
"_id",
|
||||||
"_index",
|
"_index",
|
||||||
"_parent",
|
"_parent",
|
||||||
"_percolate",
|
"_percolate",
|
||||||
|
"_retry_on_conflict",
|
||||||
"_routing",
|
"_routing",
|
||||||
"_timestamp",
|
"_timestamp",
|
||||||
"routing",
|
|
||||||
"_type",
|
"_type",
|
||||||
"_version",
|
"_version",
|
||||||
"_version_type",
|
"_version_type",
|
||||||
"_id",
|
"parent",
|
||||||
"retry_on_conflict",
|
|
||||||
"pipeline",
|
"pipeline",
|
||||||
|
"retry_on_conflict",
|
||||||
|
"routing",
|
||||||
|
"version",
|
||||||
|
"version_type",
|
||||||
):
|
):
|
||||||
if key in data:
|
if key in data:
|
||||||
if key == "_routing":
|
if key in ["_parent", "_retry_on_conflict", "_routing", "_version", "_version_type"]:
|
||||||
action[op_type]["routing"] = data.pop(key)
|
action[op_type][key[1:]] = data.pop(key)
|
||||||
else:
|
else:
|
||||||
action[op_type][key] = data.pop(key)
|
action[op_type][key] = data.pop(key)
|
||||||
|
|
||||||
@@ -442,7 +446,9 @@ def scan(
|
|||||||
yield hit
|
yield hit
|
||||||
|
|
||||||
# check if we have any errors
|
# check if we have any errors
|
||||||
if (resp["_shards"]["successful"] + resp["_shards"]["skipped"]) < resp["_shards"]["total"]:
|
if (resp["_shards"]["successful"] + resp["_shards"]["skipped"]) < resp[
|
||||||
|
"_shards"
|
||||||
|
]["total"]:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Scroll request has only succeeded on %d (+%d skipped) shards out of %d.",
|
"Scroll request has only succeeded on %d (+%d skipped) shards out of %d.",
|
||||||
resp["_shards"]["successful"],
|
resp["_shards"]["successful"],
|
||||||
@@ -453,7 +459,11 @@ def scan(
|
|||||||
raise ScanError(
|
raise ScanError(
|
||||||
scroll_id,
|
scroll_id,
|
||||||
"Scroll request has only succeeded on %d (+%d skiped) shards out of %d."
|
"Scroll request has only succeeded on %d (+%d skiped) shards out of %d."
|
||||||
% (resp["_shards"]["successful"], resp["_shards"]["skipped"], resp["_shards"]["total"]),
|
% (
|
||||||
|
resp["_shards"]["successful"],
|
||||||
|
resp["_shards"]["skipped"],
|
||||||
|
resp["_shards"]["total"],
|
||||||
|
),
|
||||||
)
|
)
|
||||||
resp = client.scroll(
|
resp = client.scroll(
|
||||||
body={"scroll_id": scroll_id, "scroll": scroll}, **scroll_kwargs
|
body={"scroll_id": scroll_id, "scroll": scroll}, **scroll_kwargs
|
||||||
|
|||||||
Reference in New Issue
Block a user