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 short
ALL
Flag to pass toTermsEnum.postings(PostingsEnum, int)
to get positions, payloads and offsets in the returned enumstatic short
FREQS
Flag to pass toTermsEnum.postings(PostingsEnum, int)
if you require term frequencies in the returned enum.static short
NONE
Flag to pass toTermsEnum.postings(PostingsEnum, int)
if you don't require per-document postings in the returned enum.static short
OFFSETS
Flag to pass toTermsEnum.postings(PostingsEnum, int)
if you require offsets in the returned enum.static short
PAYLOADS
Flag to pass toTermsEnum.postings(PostingsEnum, int)
if you require payloads in the returned enum.static short
POSITIONS
Flag 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 protected
PostingsEnum()
Sole constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract int
endOffset()
Returns end offset for the current position, or -1 if offsets were not indexed.static boolean
featureRequested(int flags, short feature)
Returns true if the given feature is requested in the flags, false otherwise.abstract int
freq()
Returns term frequency in the current document, or 1 if the field was indexed withIndexOptions.DOCS
.abstract BytesRef
getPayload()
Returns the payload at this position, or null if no payload was indexed.abstract int
nextPosition()
Returns the next position, or -1 if positions were not indexed.abstract int
startOffset()
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 IOException
Returns 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
PostingsEnum
was obtain withNONE
, the result of this method is undefined.- Throws:
IOException
-
nextPosition
public abstract int nextPosition() throws IOException
Returns 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 IOException
Returns start offset for the current position, or -1 if offsets were not indexed.- Throws:
IOException
-
endOffset
public abstract int endOffset() throws IOException
Returns 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
-
-