Class DocSet

  • All Implemented Interfaces:
    Cloneable, org.apache.lucene.util.Accountable
    Direct Known Subclasses:
    BitDocSet, SortedIntDocSet

    public abstract class DocSet
    extends Object
    implements org.apache.lucene.util.Accountable, Cloneable
    An immutable ordered set of Lucene Document Ids. It's similar to a Lucene DocIdSet. Solr never puts a deleted document into a DocSet.

    WARNING: Any DocSet returned from SolrIndexSearcher should not be modified as it may have been retrieved from a cache and could be shared.

    • Field Summary

      • Fields inherited from interface org.apache.lucene.util.Accountable

        NULL_ACCOUNTABLE
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void addAllTo​(org.apache.lucene.util.FixedBitSet target)
      Adds all the docs from this set to the target.
      abstract DocSet andNot​(DocSet other)
      Returns the documents in this set that are not in the other set.
      int andNotSize​(DocSet other)
      Returns the number of documents in this set that are not in the other set.
      abstract DocSet clone()  
      static DocSet empty()
      An empty instance (has no docs).
      abstract boolean exists​(int docid)
      Returns true if a document is in the DocSet.
      abstract org.apache.lucene.util.Bits getBits()
      A Bits that has fast random access (as is generally required of Bits).
      protected abstract org.apache.lucene.util.FixedBitSet getFixedBitSet()  
      protected abstract org.apache.lucene.util.FixedBitSet getFixedBitSetClone()  
      abstract DocSet intersection​(DocSet other)
      Returns the intersection of this set with another set.
      abstract int intersectionSize​(DocSet other)
      Returns the number of documents of the intersection of this set with another set.
      abstract boolean intersects​(DocSet other)
      Returns true if these sets have any elements in common
      abstract DocIterator iterator()
      Returns an ordered iterator of the documents in the set.
      abstract org.apache.lucene.search.DocIdSetIterator iterator​(org.apache.lucene.index.LeafReaderContext ctx)
      Returns an ordered iterator of the documents in the set for the specified LeafReaderContext.
      abstract org.apache.lucene.search.Query makeQuery()
      Returns a Query matching these documents with a score of 1.
      abstract int size()
      Returns the number of documents in the set.
      abstract DocSet union​(DocSet other)
      Returns the union of this set with another set.
      int unionSize​(DocSet other)
      Returns the number of documents of the union of this set with another set.
      • Methods inherited from interface org.apache.lucene.util.Accountable

        getChildResources, ramBytesUsed
    • Method Detail

      • empty

        public static DocSet empty()
        An empty instance (has no docs).
      • size

        public abstract int size()
        Returns the number of documents in the set.
      • exists

        public abstract boolean exists​(int docid)
        Returns true if a document is in the DocSet. If you want to be guaranteed fast random access, use getBits() instead.
      • iterator

        public abstract DocIterator iterator()
        Returns an ordered iterator of the documents in the set. Any scoring information is meaningless.
      • iterator

        public abstract org.apache.lucene.search.DocIdSetIterator iterator​(org.apache.lucene.index.LeafReaderContext ctx)
        Returns an ordered iterator of the documents in the set for the specified LeafReaderContext. NOTE: may return null if there are no matching documents for this leaf.
      • intersection

        public abstract DocSet intersection​(DocSet other)
        Returns the intersection of this set with another set. Neither set is modified - a new DocSet is created and returned.
        Returns:
        a DocSet representing the intersection
      • intersectionSize

        public abstract int intersectionSize​(DocSet other)
        Returns the number of documents of the intersection of this set with another set. May be more efficient than actually creating the intersection and then getting its size.
      • intersects

        public abstract boolean intersects​(DocSet other)
        Returns true if these sets have any elements in common
      • union

        public abstract DocSet union​(DocSet other)
        Returns the union of this set with another set. Neither set is modified - a new DocSet is created and returned.
        Returns:
        a DocSet representing the union
      • unionSize

        public int unionSize​(DocSet other)
        Returns the number of documents of the union of this set with another set. May be more efficient than actually creating the union and then getting its size.
      • andNot

        public abstract DocSet andNot​(DocSet other)
        Returns the documents in this set that are not in the other set. Neither set is modified - a new DocSet is created and returned.
        Returns:
        a DocSet representing this AND NOT other
      • andNotSize

        public int andNotSize​(DocSet other)
        Returns the number of documents in this set that are not in the other set.
      • makeQuery

        public abstract org.apache.lucene.search.Query makeQuery()
        Returns a Query matching these documents with a score of 1. Note that DocSets do not refer to deleted docs.
      • addAllTo

        public abstract void addAllTo​(org.apache.lucene.util.FixedBitSet target)
        Adds all the docs from this set to the target. The target should be sized large enough to accommodate all of the documents before calling this method.
      • getBits

        public abstract org.apache.lucene.util.Bits getBits()
        A Bits that has fast random access (as is generally required of Bits). It may be necessary to do work to build this.
      • getFixedBitSet

        protected abstract org.apache.lucene.util.FixedBitSet getFixedBitSet()
      • getFixedBitSetClone

        protected abstract org.apache.lucene.util.FixedBitSet getFixedBitSetClone()