Package org.apache.lucene.index
Class PostingsEnum
- java.lang.Object
-
- org.apache.lucene.search.DocIdSetIterator
-
- org.apache.lucene.index.PostingsEnum
-
- Direct Known Subclasses:
FilterLeafReader.FilterPostingsEnum,ImpactsEnum,MultiPhraseQuery.UnionPostingsEnum,MultiPostingsEnum
public abstract class PostingsEnum extends DocIdSetIterator
Iterates through the postings. NOTE: you must first callDocIdSetIterator.nextDoc()before using any of the per-doc methods.
-
-
Field Summary
Fields Modifier and Type Field Description static shortALLFlag to pass toTermsEnum.postings(PostingsEnum, int)to get positions, payloads and offsets in the returned enumstatic shortFREQSFlag to pass toTermsEnum.postings(PostingsEnum, int)if you require term frequencies in the returned enum.static shortNONEFlag to pass toTermsEnum.postings(PostingsEnum, int)if you don't require per-document postings in the returned enum.static shortOFFSETSFlag to pass toTermsEnum.postings(PostingsEnum, int)if you require offsets in the returned enum.static shortPAYLOADSFlag to pass toTermsEnum.postings(PostingsEnum, int)if you require payloads in the returned enum.static shortPOSITIONSFlag to pass toTermsEnum.postings(PostingsEnum, int)if you require term positions in the returned enum.-
Fields inherited from class org.apache.lucene.search.DocIdSetIterator
NO_MORE_DOCS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPostingsEnum()Sole constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intendOffset()Returns end offset for the current position, or -1 if offsets were not indexed.static booleanfeatureRequested(int flags, short feature)Returns true if the given feature is requested in the flags, false otherwise.abstract intfreq()Returns term frequency in the current document, or 1 if the field was indexed withIndexOptions.DOCS.abstract BytesRefgetPayload()Returns the payload at this position, or null if no payload was indexed.abstract intnextPosition()Returns the next position, or -1 if positions were not indexed.abstract intstartOffset()Returns start offset for the current position, or -1 if offsets were not indexed.-
Methods inherited from class org.apache.lucene.search.DocIdSetIterator
advance, all, cost, docID, empty, nextDoc, range, slowAdvance
-
-
-
-
Field Detail
-
NONE
public static final short NONE
Flag to pass toTermsEnum.postings(PostingsEnum, int)if you don't require per-document postings in the returned enum.- See Also:
- Constant Field Values
-
FREQS
public static final short FREQS
Flag to pass toTermsEnum.postings(PostingsEnum, int)if you require term frequencies in the returned enum.- See Also:
- Constant Field Values
-
POSITIONS
public static final short POSITIONS
Flag to pass toTermsEnum.postings(PostingsEnum, int)if you require term positions in the returned enum.- See Also:
- Constant Field Values
-
OFFSETS
public static final short OFFSETS
Flag to pass toTermsEnum.postings(PostingsEnum, int)if you require offsets in the returned enum.- See Also:
- Constant Field Values
-
PAYLOADS
public static final short PAYLOADS
Flag to pass toTermsEnum.postings(PostingsEnum, int)if you require payloads in the returned enum.- See Also:
- Constant Field Values
-
ALL
public static final short ALL
Flag to pass toTermsEnum.postings(PostingsEnum, int)to get positions, payloads and offsets in the returned enum- See Also:
- Constant Field Values
-
-
Method Detail
-
featureRequested
public static boolean featureRequested(int flags, short feature)Returns true if the given feature is requested in the flags, false otherwise.
-
freq
public abstract int freq() throws IOExceptionReturns term frequency in the current document, or 1 if the field was indexed withIndexOptions.DOCS. Do not call this beforeDocIdSetIterator.nextDoc()is first called, nor afterDocIdSetIterator.nextDoc()returnsDocIdSetIterator.NO_MORE_DOCS.NOTE: if the
PostingsEnumwas obtain withNONE, the result of this method is undefined.- Throws:
IOException
-
nextPosition
public abstract int nextPosition() throws IOExceptionReturns the next position, or -1 if positions were not indexed. Calling this more thanfreq()times is undefined.- Throws:
IOException
-
startOffset
public abstract int startOffset() throws IOExceptionReturns start offset for the current position, or -1 if offsets were not indexed.- Throws:
IOException
-
endOffset
public abstract int endOffset() throws IOExceptionReturns end offset for the current position, or -1 if offsets were not indexed.- Throws:
IOException
-
getPayload
public abstract BytesRef getPayload() throws IOException
Returns the payload at this position, or null if no payload was indexed. You should not modify anything (neither members of the returned BytesRef nor bytes in the byte[]).- Throws:
IOException
-
-