Package org.apache.lucene.queries
Class BooleanFilter
- java.lang.Object
-
- org.apache.lucene.search.Filter
-
- org.apache.lucene.queries.BooleanFilter
-
- All Implemented Interfaces:
java.lang.Iterable<FilterClause>
public class BooleanFilter extends Filter implements java.lang.Iterable<FilterClause>
A container Filter that allows Boolean composition of Filters. Filters are allocated into one of three logical constructs; SHOULD, MUST NOT, MUST The results Filter BitSet is constructed as follows: SHOULD Filters are OR'd together The resulting Filter is NOT'd with the NOT Filters The resulting Filter is AND'd with the MUST Filters
-
-
Constructor Summary
Constructors Constructor Description BooleanFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(FilterClause filterClause)Adds a new FilterClause to the Boolean Filter containervoidadd(Filter filter, BooleanClause.Occur occur)java.util.List<FilterClause>clauses()Returns the list of clausesbooleanequals(java.lang.Object obj)DocIdSetgetDocIdSet(AtomicReaderContext context, Bits acceptDocs)Returns the a DocIdSetIterator representing the Boolean composition of the filters that have been added.inthashCode()java.util.Iterator<FilterClause>iterator()Returns an iterator on the clauses in this query.java.lang.StringtoString()Prints a user-readable version of this Filter.
-
-
-
Method Detail
-
getDocIdSet
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws java.io.IOException
Returns the a DocIdSetIterator representing the Boolean composition of the filters that have been added.- 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:
java.io.IOException
-
add
public void add(FilterClause filterClause)
Adds a new FilterClause to the Boolean Filter container- Parameters:
filterClause- A FilterClause object containing a Filter and an Occur parameter
-
add
public final void add(Filter filter, BooleanClause.Occur occur)
-
clauses
public java.util.List<FilterClause> clauses()
Returns the list of clauses
-
iterator
public final java.util.Iterator<FilterClause> iterator()
Returns an iterator on the clauses in this query. It implements theIterableinterface to make it possible to do:for (FilterClause clause : booleanFilter) {}- Specified by:
iteratorin interfacejava.lang.Iterable<FilterClause>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Prints a user-readable version of this Filter.- Overrides:
toStringin classjava.lang.Object
-
-