Skip to content

Commit

Permalink
LUCENE-10464, LUCENE-10477: WeightedSpanTermExtractor.extractWeighted…
Browse files Browse the repository at this point in the history
…SpanTerms to rewrite sufficiently (#737)
  • Loading branch information
cpoerschke authored Mar 22, 2022
1 parent 28d3adc commit ca252d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ protected void extractWeightedSpanTerms(
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));
}
Expand Down

0 comments on commit ca252d6

Please sign in to comment.