Package org.apache.lucene.queries
Class ChainedFilter
java.lang.Object
org.apache.lucene.search.Filter
org.apache.lucene.queries.ChainedFilter
Allows multiple Filters to be chained.
Logical operations such as NOT and XOR
are applied between filters. One operation can be used
for all filters, or a specific operation can be declared
for each filter.
Order in which filters are called depends on the position of the filter in the chain. It's probably more efficient to place the most restrictive filters /least computationally-intensive filters first.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChainedFilter(Filter[] chain) Ctor.ChainedFilter(Filter[] chain, int logic) Ctor.ChainedFilter(Filter[] chain, int[] logicArray) Ctor. -
Method Summary
Modifier and TypeMethodDescriptiongetDocIdSet(AtomicReaderContext context, Bits acceptDocs) toString()
-
Field Details
-
OR
public static final int OR- See Also:
-
AND
public static final int AND- See Also:
-
ANDNOT
public static final int ANDNOT- See Also:
-
XOR
public static final int XOR- See Also:
-
DEFAULT
public static final int DEFAULTLogical operation when none is declared. Defaults to OR.- See Also:
-
-
Constructor Details
-
ChainedFilter
Ctor.- Parameters:
chain- The chain of filters
-
ChainedFilter
Ctor.- Parameters:
chain- The chain of filterslogicArray- Logical operations to apply between filters
-
ChainedFilter
Ctor.- Parameters:
chain- The chain of filterslogic- Logical operation to apply to ALL filters
-
-
Method Details
-
getDocIdSet
- Specified by:
getDocIdSetin classFilter- Parameters:
context- aAtomicReaderContextinstance opened on the index currently searched on. Note, it is likely that the provided reader info does not represent the whole underlying index i.e. if the index has more than one segment the given reader only represents a single segment. The provided context is always an atomic context, so you can callAtomicReader.fields()on the context's reader, for example.acceptDocs- Bits that represent the allowable docs to match (typically deleted docs but possibly filtering other documents)- Returns:
- a DocIdSet that provides the documents which should be permitted or
prohibited in search results. NOTE:
nullshould be returned if the filter doesn't accept any documents otherwise internal optimization might not apply in the case an emptyDocIdSetis returned. - Throws:
IOException
-
toString
-