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| Modifier and Type | Class and Description |
|---|---|
static class |
FilteredQuery.FilterStrategy
Abstract class that defines how the filter (
DocIdSet) applied during document collection. |
static class |
FilteredQuery.RandomAccessFilterStrategy
A
FilteredQuery.FilterStrategy that conditionally uses a random access filter if
the given DocIdSet supports random access (returns a non-null value
from DocIdSet.bits()) and
FilteredQuery.RandomAccessFilterStrategy.useRandomAccess(Bits, int) returns
true. |
| Modifier and Type | Field and Description |
|---|---|
static FilteredQuery.FilterStrategy |
LEAP_FROG_FILTER_FIRST_STRATEGY
A filter strategy that uses a "leap-frog" approach (also called "zig-zag join").
|
static FilteredQuery.FilterStrategy |
LEAP_FROG_QUERY_FIRST_STRATEGY
A filter strategy that uses a "leap-frog" approach (also called "zig-zag join").
|
static FilteredQuery.FilterStrategy |
QUERY_FIRST_FILTER_STRATEGY
|
static FilteredQuery.FilterStrategy |
RANDOM_ACCESS_FILTER_STRATEGY
A
FilteredQuery.FilterStrategy that conditionally uses a random access filter if
the given DocIdSet supports random access (returns a non-null value
from DocIdSet.bits()) and
FilteredQuery.RandomAccessFilterStrategy.useRandomAccess(Bits, int) returns
true. |
| Constructor and Description |
|---|
FilteredQuery(Query query,
Filter filter)
Constructs a new query which applies a filter to the results of the original query.
|
FilteredQuery(Query query,
Filter filter,
FilteredQuery.FilterStrategy strategy)
Expert: 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
|
FilteredQuery.FilterStrategy |
getFilterStrategy()
Returns this FilteredQuery's
FilteredQuery.FilterStrategy |
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.
|
public static final FilteredQuery.FilterStrategy RANDOM_ACCESS_FILTER_STRATEGY
FilteredQuery.FilterStrategy that conditionally uses a random access filter if
the given DocIdSet supports random access (returns a non-null value
from DocIdSet.bits()) and
FilteredQuery.RandomAccessFilterStrategy.useRandomAccess(Bits, int) returns
true. Otherwise this strategy falls back to a "zig-zag join" (
LEAP_FROG_FILTER_FIRST_STRATEGY) strategy.
Note: this strategy is the default strategy in FilteredQuery
public static final FilteredQuery.FilterStrategy LEAP_FROG_FILTER_FIRST_STRATEGY
Note: This strategy uses the filter to lead the iteration.
public static final FilteredQuery.FilterStrategy LEAP_FROG_QUERY_FIRST_STRATEGY
Note: This strategy uses the query to lead the iteration.
public static final FilteredQuery.FilterStrategy QUERY_FIRST_FILTER_STRATEGY
Scorer first and consults the
filter DocIdSet for each matched document.
Note: this strategy requires a DocIdSet.bits() to return a non-null value. Otherwise
this strategy falls back to LEAP_FROG_QUERY_FIRST_STRATEGY
Use this strategy if the filter computation is more expensive than document scoring or if the filter has a linear running time to compute the next matching doc like exact geo distances.
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.public FilteredQuery(Query query, Filter filter, FilteredQuery.FilterStrategy strategy)
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.strategy - a filter strategy used to create a filtered scorer.FilteredQuery.FilterStrategypublic Weight createWeight(IndexSearcher searcher) throws IOException
createWeight in class QueryIOExceptionpublic Query rewrite(IndexReader reader) throws IOException
MatchAllDocsQuery it returns a ConstantScoreQuery. Otherwise
it returns a new FilteredQuery wrapping the rewritten query.rewrite in class QueryIOExceptionpublic final Query getQuery()
public final Filter getFilter()
public FilteredQuery.FilterStrategy getFilterStrategy()
FilteredQuery.FilterStrategypublic void extractTerms(Set<Term> terms)
Queryrewritten form.extractTerms in class Querypublic boolean equals(Object o)
o is equal to this.Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.