public class FilteredQuery extends Query
Note: the bits are retrieved from the filter each time this query is used in a search - use a CachingWrapperFilter to avoid regenerating the bits every time.
CachingWrapperFilter
Constructor and Description |
---|
FilteredQuery(Query query,
Filter filter)
Constructs a new query which applies a filter to the results of the original query.
|
Modifier and Type | Method and Description |
---|---|
Weight |
createWeight(IndexSearcher searcher)
Returns a Weight that applies the filter to the enclosed query's Weight.
|
boolean |
equals(Object o)
Returns true iff
o is equal to this. |
void |
extractTerms(Set<Term> terms)
Expert: adds all terms occurring in this query to the terms set.
|
Filter |
getFilter()
Returns this FilteredQuery's filter
|
Query |
getQuery()
Returns this FilteredQuery's (unfiltered) Query
|
int |
hashCode()
Returns a hash code value for this object.
|
Query |
rewrite(IndexReader reader)
Rewrites the query.
|
String |
toString(String s)
Prints a user-readable version of this query.
|
protected boolean |
useRandomAccess(Bits bits,
int firstFilterDoc)
Expert: decides if a filter should be executed as "random-access" or not.
|
public FilteredQuery(Query query, Filter filter)
Filter.getDocIdSet(org.apache.lucene.index.AtomicReaderContext, org.apache.lucene.util.Bits)
will be called every time this query is used in a search.query
- Query to be filtered, cannot be null
.filter
- Filter to apply to query results, cannot be null
.protected boolean useRandomAccess(Bits bits, int firstFilterDoc)
public Weight createWeight(IndexSearcher searcher) throws IOException
createWeight
in class Query
IOException
public Query rewrite(IndexReader reader) throws IOException
MatchAllDocsQuery
it returns a ConstantScoreQuery
. Otherwise
it returns a new FilteredQuery
wrapping the rewritten query.rewrite
in class Query
IOException
public final Query getQuery()
public final Filter getFilter()
public void extractTerms(Set<Term> terms)
Query
rewritten
form.extractTerms
in class Query
public boolean equals(Object o)
o
is equal to this.Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.