Skip to content

Commit

Permalink
Call weight.getQuery().toString() once per query instead of once per …
Browse files Browse the repository at this point in the history
…leaf (#524)
  • Loading branch information
sarthakn7 authored Dec 2, 2022
1 parent 829ad04 commit cb25af8
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ public static LeafSlice[] slices(
@Override
protected void search(List<LeafReaderContext> leaves, Weight weight, Collector collector)
throws IOException {
boolean isDrillSidewaysQueryOrCompletionQuery =
weight.getQuery() instanceof CompletionQuery
|| weight.getQuery().toString().contains("DrillSidewaysQuery");
for (LeafReaderContext ctx : leaves) { // search each subreader
// we force the use of Scorer (not BulkScorer) to make sure
// that the scorer passed to LeafCollector.setScorer supports
Expand All @@ -251,8 +254,7 @@ protected void search(List<LeafReaderContext> leaves, Weight weight, Collector c
// continue with the following leaf
continue;
}
if (weight.getQuery().toString().contains("DrillSidewaysQuery")
|| weight.getQuery() instanceof CompletionQuery) {
if (isDrillSidewaysQueryOrCompletionQuery) {
BulkScorer scorer = weight.bulkScorer(ctx);
if (scorer != null) {
try {
Expand Down

0 comments on commit cb25af8

Please sign in to comment.