public class CachingWrapperQuery extends Query implements Accountable
Query
's result and caches it when scores are not
needed. The purpose is to allow queries to simply care about matching and
scoring, and then wrap with this class to add caching.Constructor and Description |
---|
CachingWrapperQuery(Query query)
Same as
CachingWrapperQuery(Query, QueryCachingPolicy)
but enforces the use of the
QueryCachingPolicy.CacheOnLargeSegments.DEFAULT policy. |
CachingWrapperQuery(Query query,
QueryCachingPolicy policy)
Wraps another query's result and caches it according to the provided policy.
|
Modifier and Type | Method and Description |
---|---|
protected DocIdSet |
cacheImpl(DocIdSetIterator iterator,
LeafReader reader)
Default cache implementation: uses
RoaringDocIdSet . |
CachingWrapperQuery |
clone()
Returns a clone of this query.
|
Weight |
createWeight(IndexSearcher searcher,
boolean needsScores)
Expert: Constructs an appropriate Weight implementation for this query.
|
boolean |
equals(Object o) |
float |
getBoost()
Gets the boost for this clause.
|
Collection<Accountable> |
getChildResources()
Returns nested resources of this class.
|
Query |
getQuery()
Gets the contained query.
|
int |
hashCode() |
long |
ramBytesUsed()
Return the memory usage of this object in bytes.
|
Query |
rewrite(IndexReader reader)
Expert: called to re-write queries into primitive queries.
|
void |
setBoost(float b)
Sets the boost for this query clause to
b . |
String |
toString(String field)
Prints a query to a string, with
field assumed to be the
default field and omitted. |
extractTerms, toString
public CachingWrapperQuery(Query query, QueryCachingPolicy policy)
query
- Query to cache results ofpolicy
- policy defining which filters should be cached on which segmentspublic CachingWrapperQuery(Query query)
CachingWrapperQuery(Query, QueryCachingPolicy)
but enforces the use of the
QueryCachingPolicy.CacheOnLargeSegments.DEFAULT
policy.public CachingWrapperQuery clone()
Query
public Query getQuery()
public float getBoost()
Query
b
. The boost is 1.0 by default.public void setBoost(float b)
Query
b
. Documents
matching this clause will (in addition to the normal weightings) have
their score multiplied by b
.protected DocIdSet cacheImpl(DocIdSetIterator iterator, LeafReader reader) throws IOException
RoaringDocIdSet
.IOException
public Query rewrite(IndexReader reader) throws IOException
Query
rewrite
in class Query
IOException
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException
Query
Only implemented by primitive queries, which re-write to themselves.
createWeight
in class Query
needsScores
- True if document scores (Scorer.score()
) or match
frequencies (Scorer.freq()
) are needed.IOException
public String toString(String field)
Query
field
assumed to be the
default field and omitted.public long ramBytesUsed()
Accountable
ramBytesUsed
in interface Accountable
public Collection<Accountable> getChildResources()
Accountable
getChildResources
in interface Accountable
Accountables
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.