|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.lucene.index.TermsEnum
org.apache.lucene.index.FilteredTermsEnum
public abstract class FilteredTermsEnum
Abstract class for enumerating a subset of all terms.
Term enumerations are always ordered by
getComparator(). 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.
| Nested Class Summary | |
|---|---|
protected static class |
FilteredTermsEnum.AcceptStatus
Return value, if term should be accepted or the iteration should END. |
| Nested classes/interfaces inherited from class org.apache.lucene.index.TermsEnum |
|---|
TermsEnum.SeekStatus |
| Field Summary |
|---|
| Fields inherited from class org.apache.lucene.index.TermsEnum |
|---|
EMPTY |
| Constructor Summary | |
|---|---|
FilteredTermsEnum(TermsEnum tenum)
Creates a filtered TermsEnum on a terms enum. |
|
FilteredTermsEnum(TermsEnum tenum,
boolean startWithSeek)
Creates a filtered TermsEnum on a terms enum. |
|
| Method Summary | |
|---|---|
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. |
DocsEnum |
docs(Bits bits,
DocsEnum reuse,
int flags)
Get DocsEnum for the current term, with
control over whether freqs are required. |
DocsAndPositionsEnum |
docsAndPositions(Bits bits,
DocsAndPositionsEnum reuse,
int flags)
Get DocsAndPositionsEnum for the current term,
with control over whether offsets and payloads are
required. |
Comparator<BytesRef> |
getComparator()
Return the BytesRef Comparator used to sort terms provided by the
iterator. |
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. |
TermsEnum.SeekStatus |
seekCeil(BytesRef term,
boolean useCache)
This enum does not support seeking! |
boolean |
seekExact(BytesRef term,
boolean useCache)
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). |
| Methods inherited from class org.apache.lucene.index.TermsEnum |
|---|
docs, docsAndPositions, seekCeil |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FilteredTermsEnum(TermsEnum tenum)
TermsEnum on a terms enum.
tenum - the terms enumeration to filter.
public FilteredTermsEnum(TermsEnum tenum,
boolean startWithSeek)
TermsEnum on a terms enum.
tenum - the terms enumeration to filter.| Method Detail |
|---|
protected abstract FilteredTermsEnum.AcceptStatus accept(BytesRef term)
throws IOException
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 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.
IOExceptionpublic AttributeSource attributes()
AttributeSource
is shared with the delegate TermsEnum.
attributes in class TermsEnum
public BytesRef term()
throws IOException
TermsEnum
term in class TermsEnumIOExceptionpublic Comparator<BytesRef> getComparator()
BytesRefIteratorBytesRef Comparator used to sort terms provided by the
iterator. This may return null if there are no items or the iterator is not
sorted. Callers may invoke this method many times, so it's best to cache a
single instance & reuse it.
public int docFreq()
throws IOException
TermsEnumTermsEnum.SeekStatus.END.
docFreq in class TermsEnumIOException
public long totalTermFreq()
throws IOException
TermsEnum
totalTermFreq in class TermsEnumIOException
public boolean seekExact(BytesRef term,
boolean useCache)
throws IOException
seekExact in class TermsEnumUnsupportedOperationException - In general, subclasses do not
support seeking.
IOException
public TermsEnum.SeekStatus seekCeil(BytesRef term,
boolean useCache)
throws IOException
seekCeil in class TermsEnumUnsupportedOperationException - In general, subclasses do not
support seeking.
IOException
public void seekExact(long ord)
throws IOException
seekExact in class TermsEnumUnsupportedOperationException - In general, subclasses do not
support seeking.
IOException
public long ord()
throws IOException
TermsEnumUnsupportedOperationException). Do not call this
when the enum is unpositioned.
ord in class TermsEnumIOException
public DocsEnum docs(Bits bits,
DocsEnum reuse,
int flags)
throws IOException
TermsEnumDocsEnum for the current term, with
control over whether freqs are required. Do not
call this when the enum is unpositioned. This method
will not return null.
docs in class TermsEnumbits - unset bits are documents that should not
be returnedreuse - pass a prior DocsEnum for possible reuseflags - specifies which optional per-document values
you require; see DocsEnum.FLAG_FREQS
IOExceptionTermsEnum.docs(Bits, DocsEnum, int)
public DocsAndPositionsEnum docsAndPositions(Bits bits,
DocsAndPositionsEnum reuse,
int flags)
throws IOException
TermsEnumDocsAndPositionsEnum for the current term,
with control over whether offsets and payloads are
required. Some codecs may be able to optimize their
implementation when offsets and/or payloads are not required.
Do not call this when the enum is unpositioned. This
will return null if positions were not indexed.
docsAndPositions in class TermsEnumbits - unset bits are documents that should not
be returnedreuse - pass a prior DocsAndPositionsEnum for possible reuseflags - specifies which optional per-position values you
require; see DocsAndPositionsEnum.FLAG_OFFSETS and
DocsAndPositionsEnum.FLAG_PAYLOADS.
IOException
public void seekExact(BytesRef term,
TermState state)
throws IOException
seekExact in class TermsEnumterm - the term the TermState corresponds tostate - the TermState
UnsupportedOperationException - In general, subclasses do not
support seeking.
IOException
public TermState termState()
throws IOException
termState in class TermsEnumIOExceptionTermState,
TermsEnum.seekExact(BytesRef, TermState)
public BytesRef next()
throws 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.
IOException - If there is a low-level I/O error.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||