Skip to content

Commit 0edc27c

Browse files
committed
Make can-match support already skipped shard iterators
1 parent 3f86fb8 commit 0edc27c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

server/src/main/java/org/elasticsearch/action/search/CanMatchPreFilterSearchPhase.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ private void runCoordinatorRewritePhase() {
186186
assert assertSearchCoordinationThread();
187187
final List<SearchShardIterator> matchedShardLevelRequests = new ArrayList<>();
188188
for (SearchShardIterator searchShardIterator : shardsIts) {
189+
if (searchShardIterator.prefiltered() == false && searchShardIterator.skip()) {
190+
// This implies the iterator was skipped due to an index level block,
191+
// not a remote can-match run.
192+
continue;
193+
}
194+
189195
final CanMatchNodeRequest canMatchNodeRequest = new CanMatchNodeRequest(
190196
request,
191197
searchShardIterator.getOriginalIndices().indicesOptions(),

server/src/main/java/org/elasticsearch/action/search/SearchShardIterator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public SearchShardIterator(@Nullable String clusterAlias, ShardId shardId, List<
6060
* @param shardId shard id of the group
6161
* @param shards shards to iterate
6262
* @param originalIndices the indices that the search request originally related to (before any rewriting happened)
63-
* @param skip if true, then this group won't have matches, and it can be safely skipped from the search
63+
* @param skip if true, then this group won't have matches (due to an index level block),
64+
* and it can be safely skipped from the search
6465
*/
6566
public SearchShardIterator(
6667
@Nullable String clusterAlias,
@@ -83,7 +84,8 @@ public SearchShardIterator(
8384
* @param searchContextId the point-in-time specified for this group if exists
8485
* @param searchContextKeepAlive the time interval that data nodes should extend the keep alive of the point-in-time
8586
* @param prefiltered if true, then this group already executed the can_match phase
86-
* @param skip if true, then this group won't have matches, and it can be safely skipped from the search
87+
* @param skip if true, then this group won't have matches (due to can match, or an index level block),
88+
* and it can be safely skipped from the search
8789
*/
8890
public SearchShardIterator(
8991
@Nullable String clusterAlias,

0 commit comments

Comments
 (0)