Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.CollectorManager;
import org.apache.lucene.search.ConjunctionUtils;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
Expand Down Expand Up @@ -257,7 +258,15 @@ public void search(

@Override
public void search(Query query, Collector collector) throws IOException {
super.search(query, collector);
// TODO : Remove when switching to use the @org.apache.lucene.search.IndexSearcher#search(Query, CollectorManager) variant from
// @org.opensearch.search.query.QueryPhase#searchWithCollector which then calls the overridden
// search(LeafReaderContextPartition[] partitions, Weight weight, Collector collector)
query = collector.scoreMode().needsScores() ? rewrite(query) : rewrite(new ConstantScoreQuery(query));
Weight weight = createWeight(query, collector.scoreMode(), 1);
LeafSlice[] leafSlices = getSlices();
for (LeafSlice leafSlice : leafSlices) {
search(leafSlice.partitions, weight, collector);
}
searchContext.bucketCollectorProcessor().processPostCollection(collector);
}

Expand Down
Loading