Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/lucene_snapshot' into interval…
Browse files Browse the repository at this point in the history
…s_regexp_range
  • Loading branch information
mayya-sharipova committed Aug 19, 2024
2 parents 71d55c2 + 628d334 commit 616612c
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,9 @@ public <C extends Collector, T> T search(Query query, CollectorManager<C, T> col
}

/**
* Similar to the lucene implementation, with the following changes made:
* 1) postCollection is performed after each segment is collected. This is needed for aggregations, performed by search worker threads
* so it can be parallelized. Also, it needs to happen in the same thread where doc_values are read, as it consumes them and Lucene
* does not allow consuming them from a different thread.
* 2) handles the ES TimeExceededException
* */
* Same implementation as the default one in Lucene, with an additional call to postCollection in cased there are no segments.
* The rest is a plain copy from Lucene.
*/
private <C extends Collector, T> T search(Weight weight, CollectorManager<C, T> collectorManager, C firstCollector) throws IOException {
LeafSlice[] leafSlices = getSlices();
if (leafSlices.length == 0) {
Expand Down Expand Up @@ -356,14 +353,18 @@ private <C extends Collector, T> T search(Weight weight, CollectorManager<C, T>
}
}

/**
* Similar to the lucene implementation, with the following changes made:
* 1) postCollection is performed after each segment is collected. This is needed for aggregations, performed by search worker threads
* so it can be parallelized. Also, it needs to happen in the same thread where doc_values are read, as it consumes them and Lucene
* does not allow consuming them from a different thread.
* 2) handles the ES TimeExceededException
*/
@Override
public void search(List<LeafReaderContext> leaves, Weight weight, Collector collector) throws IOException {
collector.setWeight(weight);
boolean success = false;
try {
for (LeafReaderContext ctx : leaves) { // search each subreader
searchLeaf(ctx, weight, collector);
}
super.search(leaves, weight, collector);
success = true;
} catch (@SuppressWarnings("unused") TimeExceededException e) {
timeExceeded = true;
Expand Down

0 comments on commit 616612c

Please sign in to comment.