LUCENE-10464, LUCENE-10477: WeightedSpanTermExtractor.extractWeightedSpanTerms to rewrite sufficiently (#737)

This commit is contained in:
Christine Poerschke 2022-03-22 14:53:41 +00:00 committed by GitHub
parent 28d3adcf69
commit ca252d6621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -75,7 +75,8 @@ Optimizations
Bug Fixes
---------------------
(No changes)
* LUCENE-10477: Highlighter: WeightedSpanTermExtractor.extractWeightedSpanTerms to Query#rewrite
multiple times if necessary. (Christine Poerschke, Adrien Grand)
Other
---------------------

View File

@ -309,11 +309,11 @@ public class WeightedSpanTermExtractor {
final IndexSearcher searcher = new IndexSearcher(getLeafContext());
searcher.setQueryCache(null);
if (mustRewriteQuery) {
final SpanQuery rewrittenQuery = (SpanQuery) searcher.rewrite(spanQuery);
for (final String field : fieldNames) {
final SpanQuery rewrittenQuery = (SpanQuery) spanQuery.rewrite(getLeafContext().reader());
queries.put(field, rewrittenQuery);
rewrittenQuery.visit(QueryVisitor.termCollector(nonWeightedTerms));
}
rewrittenQuery.visit(QueryVisitor.termCollector(nonWeightedTerms));
} else {
spanQuery.visit(QueryVisitor.termCollector(nonWeightedTerms));
}