Skip to content

Commit

Permalink
Fixing handling of auto slices in bulk scroll requests (#43050)
Browse files Browse the repository at this point in the history
* Fixing handling of auto slices in bulk scroll requests

* adjusting assertions for tests
  • Loading branch information
benwtrent authored Jun 10, 2019
1 parent 11aa5d3 commit 596df3b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static int countSlicesBasedOnShards(ClusterSearchShardsResponse response
(sum, term) -> sum + term
));
Set<Integer> counts = new HashSet<>(countsByIndex.values());
int leastShards = Collections.min(counts);
int leastShards = counts.isEmpty() ? 1 : Collections.min(counts);
return Math.min(leastShards, AUTO_SLICE_CEILING);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,13 @@ public void testMultipleSources() throws Exception {

}

public void testMissingSources() {
BulkByScrollResponse response = updateByQuery()
.source("missing-index-*")
.refresh(true)
.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES)
.get();
assertThat(response, matcher().deleted(0).slices(hasSize(0)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,13 @@ public void testMultipleSources() throws Exception {
assertHitCount(client().prepareSearch("dest").setSize(0).get(), allDocs.size());
}

public void testMissingSources() {
BulkByScrollResponse response = updateByQuery()
.source("missing-index-*")
.refresh(true)
.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES)
.get();
assertThat(response, matcher().created(0).slices(hasSize(0)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,13 @@ public void testMultipleSources() throws Exception {
assertEquals(2, client().prepareGet(index, "test", Integer.toString(randomDoc)).get().getVersion());
}
}

public void testMissingSources() {
BulkByScrollResponse response = updateByQuery()
.source("missing-index-*")
.refresh(true)
.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES)
.get();
assertThat(response, matcher().updated(0).slices(hasSize(0)));
}
}

0 comments on commit 596df3b

Please sign in to comment.