mirror of https://github.com/apache/lucene.git
No need to rewrite queries in unified highlighter (#11807)
Since QueryVisitor added the ability to signal multi-term queries, the query rewrite call in UnifiedHighlighter has been essentially useless, and with more aggressive rewriting this is now causing bugs like #11490. We can safely remove this call. Fixes #11490
This commit is contained in:
parent
df94e6c005
commit
6bd8733fdb
|
@ -118,6 +118,8 @@ Bug Fixes
|
||||||
* GITHUB#11768: Taxonomy and SSDV faceting now correctly breaks ties by preferring smaller ordinal
|
* GITHUB#11768: Taxonomy and SSDV faceting now correctly breaks ties by preferring smaller ordinal
|
||||||
values. (Greg Miller)
|
values. (Greg Miller)
|
||||||
|
|
||||||
|
* GITHUB#11807: Don't rewrite queries in unified highlighter. (Alan Woodward)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
---------------------
|
---------------------
|
||||||
* GITHUB#11738: Optimize MultiTermQueryConstantScoreWrapper when a term is present that matches all
|
* GITHUB#11738: Optimize MultiTermQueryConstantScoreWrapper when a term is present that matches all
|
||||||
|
|
|
@ -44,7 +44,6 @@ import org.apache.lucene.index.IndexOptions;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.LeafReader;
|
import org.apache.lucene.index.LeafReader;
|
||||||
import org.apache.lucene.index.LeafReaderContext;
|
import org.apache.lucene.index.LeafReaderContext;
|
||||||
import org.apache.lucene.index.MultiReader;
|
|
||||||
import org.apache.lucene.index.ReaderUtil;
|
import org.apache.lucene.index.ReaderUtil;
|
||||||
import org.apache.lucene.index.StoredFieldVisitor;
|
import org.apache.lucene.index.StoredFieldVisitor;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
|
@ -97,18 +96,6 @@ public class UnifiedHighlighter {
|
||||||
|
|
||||||
public static final int DEFAULT_CACHE_CHARS_THRESHOLD = 524288; // ~ 1 MB (2 byte chars)
|
public static final int DEFAULT_CACHE_CHARS_THRESHOLD = 524288; // ~ 1 MB (2 byte chars)
|
||||||
|
|
||||||
static final IndexSearcher EMPTY_INDEXSEARCHER;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
IndexReader emptyReader = new MultiReader();
|
|
||||||
EMPTY_INDEXSEARCHER = new IndexSearcher(emptyReader);
|
|
||||||
EMPTY_INDEXSEARCHER.setQueryCache(null);
|
|
||||||
} catch (IOException bogus) {
|
|
||||||
throw new RuntimeException(bogus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static final LabelledCharArrayMatcher[] ZERO_LEN_AUTOMATA_ARRAY =
|
protected static final LabelledCharArrayMatcher[] ZERO_LEN_AUTOMATA_ARRAY =
|
||||||
new LabelledCharArrayMatcher[0];
|
new LabelledCharArrayMatcher[0];
|
||||||
|
|
||||||
|
@ -452,10 +439,10 @@ public class UnifiedHighlighter {
|
||||||
this.cacheFieldValCharsThreshold = builder.cacheFieldValCharsThreshold;
|
this.cacheFieldValCharsThreshold = builder.cacheFieldValCharsThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Extracts matching terms after rewriting against an empty index */
|
/** Extracts matching terms */
|
||||||
protected static Set<Term> extractTerms(Query query) throws IOException {
|
protected static Set<Term> extractTerms(Query query) {
|
||||||
Set<Term> queryTerms = new HashSet<>();
|
Set<Term> queryTerms = new HashSet<>();
|
||||||
EMPTY_INDEXSEARCHER.rewrite(query).visit(QueryVisitor.termCollector(queryTerms));
|
query.visit(QueryVisitor.termCollector(queryTerms));
|
||||||
return queryTerms;
|
return queryTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue