public abstract class FilteredTermsEnum extends TermsEnum
Term enumerations are always ordered by
BytesRef.compareTo(org.apache.lucene.util.BytesRef). Each term in the enumeration is
greater than all that precede it.
Please note: Consumers of this enum cannot
call seek(), it is forward only; it throws
UnsupportedOperationException when a seeking method
is called.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
FilteredTermsEnum.AcceptStatus
Return value, if term should be accepted or the iteration should
END. |
TermsEnum.SeekStatus| Modifier and Type | Field and Description |
|---|---|
protected BytesRef |
actualTerm
Which term the enum is currently positioned to.
|
protected TermsEnum |
tenum
The delegate
TermsEnum. |
| Constructor and Description |
|---|
FilteredTermsEnum(TermsEnum tenum)
Creates a filtered
TermsEnum on a terms enum. |
FilteredTermsEnum(TermsEnum tenum,
boolean startWithSeek)
Creates a filtered
TermsEnum on a terms enum. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract FilteredTermsEnum.AcceptStatus |
accept(BytesRef term)
Return if term is accepted, not accepted or the iteration should ended
(and possibly seek).
|
AttributeSource |
attributes()
Returns the related attributes, the returned
AttributeSource
is shared with the delegate TermsEnum. |
int |
docFreq()
Returns the number of documents containing the current
term.
|
BytesRef |
next()
Increments the iteration to the next
BytesRef in the iterator. |
protected BytesRef |
nextSeekTerm(BytesRef currentTerm)
On the first call to
next() or if accept(org.apache.lucene.util.BytesRef) returns
FilteredTermsEnum.AcceptStatus.YES_AND_SEEK or FilteredTermsEnum.AcceptStatus.NO_AND_SEEK,
this method will be called to eventually seek the underlying TermsEnum
to a new position. |
long |
ord()
Returns ordinal position for current term.
|
PostingsEnum |
postings(PostingsEnum reuse,
int flags)
Get
PostingsEnum for the current term, with
control over whether freqs, positions, offsets or payloads
are required. |
TermsEnum.SeekStatus |
seekCeil(BytesRef term)
This enum does not support seeking!
|
boolean |
seekExact(BytesRef term)
This enum does not support seeking!
|
void |
seekExact(BytesRef term,
TermState state)
This enum does not support seeking!
|
void |
seekExact(long ord)
This enum does not support seeking!
|
protected void |
setInitialSeekTerm(BytesRef term)
Use this method to set the initial
BytesRef
to seek before iterating. |
BytesRef |
term()
Returns current term.
|
TermState |
termState()
Returns the filtered enums term state
|
long |
totalTermFreq()
Returns the total number of occurrences of this term
across all documents (the sum of the freq() for each
doc that has this term).
|
protected BytesRef actualTerm
public FilteredTermsEnum(TermsEnum tenum)
TermsEnum on a terms enum.tenum - the terms enumeration to filter.protected abstract FilteredTermsEnum.AcceptStatus accept(BytesRef term) throws java.io.IOException
java.io.IOExceptionprotected final void setInitialSeekTerm(BytesRef term)
BytesRef
to seek before iterating. This is a convenience method for
subclasses that do not override nextSeekTerm(org.apache.lucene.util.BytesRef).
If the initial seek term is null (default),
the enum is empty.
You can only use this method, if you keep the default
implementation of nextSeekTerm(org.apache.lucene.util.BytesRef).
protected BytesRef nextSeekTerm(BytesRef currentTerm) throws java.io.IOException
next() or if accept(org.apache.lucene.util.BytesRef) returns
FilteredTermsEnum.AcceptStatus.YES_AND_SEEK or FilteredTermsEnum.AcceptStatus.NO_AND_SEEK,
this method will be called to eventually seek the underlying TermsEnum
to a new position.
On the first call, currentTerm will be null, later
calls will provide the term the underlying enum is positioned at.
This method returns per default only one time the initial seek term
and then null, so no repositioning is ever done.
Override this method, if you want a more sophisticated TermsEnum,
that repositions the iterator during enumeration.
If this method always returns null the enum is empty.
Please note: This method should always provide a greater term than the last enumerated term, else the behaviour of this enum violates the contract for TermsEnums.
java.io.IOExceptionpublic AttributeSource attributes()
AttributeSource
is shared with the delegate TermsEnum.attributes in class TermsEnumpublic BytesRef term() throws java.io.IOException
TermsEnumpublic int docFreq()
throws java.io.IOException
TermsEnumTermsEnum.SeekStatus.END.public long totalTermFreq()
throws java.io.IOException
TermsEnumtotalTermFreq in class TermsEnumjava.io.IOExceptionpublic boolean seekExact(BytesRef term) throws java.io.IOException
public TermsEnum.SeekStatus seekCeil(BytesRef term) throws java.io.IOException
public void seekExact(long ord)
throws java.io.IOException
public long ord()
throws java.io.IOException
TermsEnumUnsupportedOperationException). Do not call this
when the enum is unpositioned.public PostingsEnum postings(PostingsEnum reuse, int flags) throws java.io.IOException
TermsEnumPostingsEnum for the current term, with
control over whether freqs, positions, offsets or payloads
are required. Do not call this when the enum is
unpositioned. This method will not return null.
NOTE: the returned iterator may return deleted documents, so
deleted documents have to be checked on top of the PostingsEnum.
postings in class TermsEnumreuse - pass a prior PostingsEnum for possible reuseflags - specifies which optional per-document values
you require; see PostingsEnum.FREQSjava.io.IOExceptionpublic void seekExact(BytesRef term, TermState state) throws java.io.IOException
public TermState termState() throws java.io.IOException
termState in class TermsEnumjava.io.IOExceptionTermState,
TermsEnum.seekExact(BytesRef, TermState)public BytesRef next() throws java.io.IOException
BytesRefIteratorBytesRef in the iterator.
Returns the resulting BytesRef or null if the end of
the iterator is reached. The returned BytesRef may be re-used across calls
to next. After this method returns null, do not call it again: the results
are undefined.BytesRef in the iterator or null if
the end of the iterator is reached.java.io.IOException - If there is a low-level I/O error.Copyright © 2000–2025 The Apache Software Foundation. All rights reserved.