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,8 +258,15 @@

@Override
public void search(Query query, Collector collector) throws IOException {
super.search(query, collector);
searchContext.bucketCollectorProcessor().processPostCollection(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);
LeafReaderContextPartition[] partitions = (getLeafContexts() == null)
? new LeafReaderContextPartition[0]

Check warning on line 267 in server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java#L267

Added line #L267 was not covered by tests
: getLeafContexts().stream().map(LeafReaderContextPartition::createForEntireSegment).toArray(LeafReaderContextPartition[]::new);
search(partitions, weight, collector);
}

public void search(
Expand Down Expand Up @@ -297,6 +305,7 @@
searchLeaf(partition.ctx, partition.minDocId, partition.maxDocId, weight, collector);
}
}
// TODO : Make this a responsibility for the callers rather than implicitly getting it done here ?
searchContext.bucketCollectorProcessor().processPostCollection(collector);
} catch (Throwable t) {
searchContext.indexShard().getSearchOperationListener().onFailedSliceExecution(searchContext);
Expand Down
Loading