class LuceneQueryOptimizer
extends java.lang.Object
QueryFilter
s and
caches these. Only required TermQuery
s whose boost is zero and
whose term occurs in at least a certain fraction of documents are converted
to cached filters. This accelerates query constraints like language,
document format, etc., which do not affect ranking but might otherwise slow
search considerably.Modifier and Type | Field and Description |
---|---|
private java.util.LinkedHashMap |
cache |
private float |
threshold |
Constructor and Description |
---|
LuceneQueryOptimizer(int cacheSize,
float threshold)
Construct an optimizer that caches and uses filters for required
TermQuery s whose boost is zero. |
Modifier and Type | Method and Description |
---|---|
org.apache.lucene.search.TopDocs |
optimize(org.apache.lucene.search.BooleanQuery original,
org.apache.lucene.search.Searcher searcher,
int numHits,
org.apache.lucene.search.Query[] queryOut,
org.apache.lucene.search.Filter[] filterOut) |
public LuceneQueryOptimizer(int cacheSize, float threshold)
TermQuery
s whose boost is zero.cacheSize
- the number of QueryFilters to cachethreshold
- the fraction of documents which must contain termpublic org.apache.lucene.search.TopDocs optimize(org.apache.lucene.search.BooleanQuery original, org.apache.lucene.search.Searcher searcher, int numHits, org.apache.lucene.search.Query[] queryOut, org.apache.lucene.search.Filter[] filterOut) throws java.io.IOException
java.io.IOException