Skip to content

Commit d925667

Browse files
Skip can_match phase with batched execution
If batched query execution is used, anything past the coordinator rewrite phase is somewhat pointless. Just sort the shards in natural order and be done with it as if there was no can_match.
1 parent fd2cc97 commit d925667

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,14 @@ private void runCoordinatorRewritePhase() {
167167
if (matchedShardLevelRequests.isEmpty()) {
168168
finishPhase();
169169
} else {
170-
// verify missing shards only for the shards that we hit for the query
171-
checkNoMissingShards(matchedShardLevelRequests);
172-
new Round(matchedShardLevelRequests).run();
170+
if (SearchService.BATCHED_QUERY_PHASE_FEATURE_FLAG) {
171+
matchedShardLevelRequests.sort(SearchShardIterator::compareTo);
172+
listener.onResponse(matchedShardLevelRequests);
173+
} else {
174+
// verify missing shards only for the shards that we hit for the query
175+
checkNoMissingShards(matchedShardLevelRequests);
176+
new Round(matchedShardLevelRequests).run();
177+
}
173178
}
174179
}
175180

server/src/main/java/org/elasticsearch/search/SearchService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
282282
Property.NodeScope
283283
);
284284

285-
private static final boolean BATCHED_QUERY_PHASE_FEATURE_FLAG = new FeatureFlag("batched_query_phase").isEnabled();
285+
public static final boolean BATCHED_QUERY_PHASE_FEATURE_FLAG = new FeatureFlag("batched_query_phase").isEnabled();
286286

287287
/**
288288
* The size of the buffer used for memory accounting.

0 commit comments

Comments
 (0)