Take skipped shards as successful in scan helper
This commit is contained in:
@@ -442,17 +442,18 @@ def scan(
|
|||||||
yield hit
|
yield hit
|
||||||
|
|
||||||
# check if we have any errors
|
# check if we have any errors
|
||||||
if resp["_shards"]["successful"] < resp["_shards"]["total"]:
|
if (resp["_shards"]["successful"] + resp["_shards"]["skipped"]) < resp["_shards"]["total"]:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Scroll request has only succeeded on %d shards out of %d.",
|
"Scroll request has only succeeded on %d (+%d skipped) shards out of %d.",
|
||||||
resp["_shards"]["successful"],
|
resp["_shards"]["successful"],
|
||||||
|
resp["_shards"]["skipped"],
|
||||||
resp["_shards"]["total"],
|
resp["_shards"]["total"],
|
||||||
)
|
)
|
||||||
if raise_on_error:
|
if raise_on_error:
|
||||||
raise ScanError(
|
raise ScanError(
|
||||||
scroll_id,
|
scroll_id,
|
||||||
"Scroll request has only succeeded on %d shards out of %d."
|
"Scroll request has only succeeded on %d (+%d skiped) shards out of %d."
|
||||||
% (resp["_shards"]["successful"], 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
|
||||||
|
|||||||
@@ -311,12 +311,12 @@ class TestScan(ElasticsearchTestCase):
|
|||||||
mock_scroll_responses = [
|
mock_scroll_responses = [
|
||||||
{
|
{
|
||||||
"_scroll_id": "dummy_id",
|
"_scroll_id": "dummy_id",
|
||||||
"_shards": {"successful": 4, "total": 5},
|
"_shards": {"successful": 4, "total": 5, "skipped": 0},
|
||||||
"hits": {"hits": [{"scroll_data": 42}]},
|
"hits": {"hits": [{"scroll_data": 42}]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_scroll_id": "dummy_id",
|
"_scroll_id": "dummy_id",
|
||||||
"_shards": {"successful": 4, "total": 5},
|
"_shards": {"successful": 4, "total": 5, "skipped": 0},
|
||||||
"hits": {"hits": []},
|
"hits": {"hits": []},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -398,7 +398,7 @@ class TestScan(ElasticsearchTestCase):
|
|||||||
with patch.object(self, "client") as client_mock:
|
with patch.object(self, "client") as client_mock:
|
||||||
client_mock.search.return_value = {
|
client_mock.search.return_value = {
|
||||||
"_scroll_id": "dummy_id",
|
"_scroll_id": "dummy_id",
|
||||||
"_shards": {"successful": 4, "total": 5},
|
"_shards": {"successful": 4, "total": 5, "skipped": 0},
|
||||||
"hits": {"hits": [{"search_data": 1}]},
|
"hits": {"hits": [{"search_data": 1}]},
|
||||||
}
|
}
|
||||||
client_mock.scroll.side_effect = self.mock_scroll_responses
|
client_mock.scroll.side_effect = self.mock_scroll_responses
|
||||||
|
|||||||
Reference in New Issue
Block a user