Class TermsEnum

java.lang.Object
org.apache.lucene.index.TermsEnum
All Implemented Interfaces:
BytesRefIterator
Direct Known Subclasses:
BaseTermsEnum, FilteredTermsEnum, FilterLeafReader.FilterTermsEnum

public abstract class TermsEnum extends Object implements BytesRefIterator
Iterator to seek (seekCeil(BytesRef), seekExact(BytesRef)) or step through (BytesRefIterator.next() terms to obtain frequency information (docFreq()), PostingsEnum or PostingsEnum for the current term (postings(org.apache.lucene.index.PostingsEnum).

Term enumerations are always ordered by BytesRef.compareTo, which is Unicode sort order if the terms are UTF-8 bytes. Each term in the enumeration is greater than the one before it.

The TermsEnum is unpositioned when you first obtain it and you must first successfully call BytesRefIterator.next() or one of the seek methods.

WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Field Details

    • EMPTY

      public static final TermsEnum EMPTY
      An empty TermsEnum for quickly returning an empty instance e.g. in MultiTermQuery

      Please note: This enum should be unmodifiable, but it is currently possible to add Attributes to it. This should not be a problem, as the enum is always empty and the existence of unused Attributes does not matter.

  • Constructor Details

    • TermsEnum

      protected TermsEnum()
      Sole constructor. (For invocation by subclass constructors, typically implicit.)
  • Method Details