SuggestIndexSearcher.suggest catches any CollectionTerminatedException (theoretically) thrown by getLeafCollector (#12609)

This commit is contained in:
Christine Poerschke 2023-09-29 12:14:50 +01:00 committed by GitHub
parent e02f1b1d29
commit 411b7fd518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -68,8 +68,9 @@ public class SuggestIndexSearcher extends IndexSearcher {
for (LeafReaderContext context : getIndexReader().leaves()) {
BulkScorer scorer = weight.bulkScorer(context);
if (scorer != null) {
LeafCollector leafCollector = collector.getLeafCollector(context);
LeafCollector leafCollector = null;
try {
leafCollector = collector.getLeafCollector(context);
scorer.score(leafCollector, context.reader().getLiveDocs());
} catch (
@SuppressWarnings("unused")
@ -77,7 +78,9 @@ public class SuggestIndexSearcher extends IndexSearcher {
// collection was terminated prematurely
// continue with the following leaf
}
leafCollector.finish();
if (leafCollector != null) {
leafCollector.finish();
}
}
}
}