Package org.apache.lucene.search
Class FilteredQuery.RandomAccessFilterStrategy
- java.lang.Object
-
- org.apache.lucene.search.FilteredQuery.FilterStrategy
-
- org.apache.lucene.search.FilteredQuery.RandomAccessFilterStrategy
-
- Enclosing class:
- FilteredQuery
public static class FilteredQuery.RandomAccessFilterStrategy extends FilteredQuery.FilterStrategy
AFilteredQuery.FilterStrategy
that conditionally uses a random access filter if the givenDocIdSet
supports random access (returns a non-null value fromDocIdSet.bits()
) anduseRandomAccess(Bits, int)
returnstrue
. Otherwise this strategy falls back to a "zig-zag join" (FilteredQuery.LEAP_FROG_FILTER_FIRST_STRATEGY
) strategy .
-
-
Constructor Summary
Constructors Constructor Description RandomAccessFilterStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Scorer
filteredScorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Weight weight, DocIdSet docIdSet)
Returns a filteredScorer
based on this strategy.protected boolean
useRandomAccess(Bits bits, int firstFilterDoc)
Expert: decides if a filter should be executed as "random-access" or not.
-
-
-
Method Detail
-
filteredScorer
public Scorer filteredScorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Weight weight, DocIdSet docIdSet) throws IOException
Description copied from class:FilteredQuery.FilterStrategy
Returns a filteredScorer
based on this strategy.- Specified by:
filteredScorer
in classFilteredQuery.FilterStrategy
- Parameters:
context
- theAtomicReaderContext
for which to return theScorer
.scoreDocsInOrder
- specifies whether in-order scoring of documents is required. Note that if set to false (i.e., out-of-order scoring is required), this method can return whatever scoring mode it supports, as every in-order scorer is also an out-of-order one. However, an out-of-order scorer may not supportDocIdSetIterator.nextDoc()
and/orDocIdSetIterator.advance(int)
, therefore it is recommended to request an in-order scorer if use of these methods is required.topScorer
- if true,Scorer.score(Collector)
will be called; if false,DocIdSetIterator.nextDoc()
and/orDocIdSetIterator.advance(int)
will be called.weight
- theFilteredQuery
Weight
to create the filtered scorer.docIdSet
- the filterDocIdSet
to apply- Returns:
- a filtered scorer
- Throws:
IOException
- if anIOException
occurs
-
useRandomAccess
protected boolean useRandomAccess(Bits bits, int firstFilterDoc)
Expert: decides if a filter should be executed as "random-access" or not. random-access means the filter "filters" in a similar way as deleted docs are filtered in Lucene. This is faster when the filter accepts many documents. However, when the filter is very sparse, it can be faster to execute the query+filter as a conjunction in some cases. The default implementation returnstrue
if the first document accepted by the filter is < 100.
-
-