Class FilteredTermsEnum
- All Implemented Interfaces:
BytesRefIterator
- Direct Known Subclasses:
AutomatonTermsEnum,SingleTermsEnum
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumReturn value, if term should be accepted or the iteration shouldEND.Nested classes/interfaces inherited from class org.apache.lucene.index.TermsEnum
TermsEnum.SeekStatus -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFilteredTermsEnum(TermsEnum tenum) Creates a filteredTermsEnumon a terms enum.protectedFilteredTermsEnum(TermsEnum tenum, boolean startWithSeek) Creates a filteredTermsEnumon a terms enum. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract FilteredTermsEnum.AcceptStatusReturn if term is accepted, not accepted or the iteration should ended (and possibly seek).Returns the related attributes, the returnedAttributeSourceis shared with the delegateTermsEnum.intdocFreq()Returns the number of documents containing the current term.impacts(int flags) Return aImpactsEnum.next()Increments the iteration to the nextBytesRefin the iterator.protected BytesRefnextSeekTerm(BytesRef currentTerm) On the first call tonext()or ifaccept(org.apache.lucene.util.BytesRef)returnsFilteredTermsEnum.AcceptStatus.YES_AND_SEEKorFilteredTermsEnum.AcceptStatus.NO_AND_SEEK, this method will be called to eventually seek the underlying TermsEnum to a new position.longord()Returns ordinal position for current term.postings(PostingsEnum reuse, int flags) GetPostingsEnumfor the current term, with control over whether freqs, positions, offsets or payloads are required.prepareSeekExact(BytesRef text) This enum does not support seeking!This enum does not support seeking!voidseekExact(long ord) This enum does not support seeking!booleanThis enum does not support seeking!voidThis enum does not support seeking!protected final voidsetInitialSeekTerm(BytesRef term) Use this method to set the initialBytesRefto seek before iterating.term()Returns current term.Returns the filtered enums term statelongReturns the total number of occurrences of this term across all documents (the sum of the freq() for each doc that has this term).
-
Field Details
-
actualTerm
Which term the enum is currently positioned to. -
tenum
The delegateTermsEnum.
-
-
Constructor Details
-
Method Details
-
accept
Return if term is accepted, not accepted or the iteration should ended (and possibly seek).- Throws:
IOException
-
setInitialSeekTerm
Use this method to set the initialBytesRefto seek before iterating. This is a convenience method for subclasses that do not overridenextSeekTerm(org.apache.lucene.util.BytesRef). If the initial seek term isnull(default), the enum is empty.You can only use this method, if you keep the default implementation of
nextSeekTerm(org.apache.lucene.util.BytesRef). -
nextSeekTerm
On the first call tonext()or ifaccept(org.apache.lucene.util.BytesRef)returnsFilteredTermsEnum.AcceptStatus.YES_AND_SEEKorFilteredTermsEnum.AcceptStatus.NO_AND_SEEK, this method will be called to eventually seek the underlying TermsEnum to a new position. On the first call,currentTermwill benull, 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 thennull, 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
nullthe 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.
- Throws:
IOException
-
attributes
Returns the related attributes, the returnedAttributeSourceis shared with the delegateTermsEnum.- Specified by:
attributesin classTermsEnum
-
term
Description copied from class:TermsEnumReturns current term. Do not call this when the enum is unpositioned.- Specified by:
termin classTermsEnum- Throws:
IOException
-
docFreq
Description copied from class:TermsEnumReturns the number of documents containing the current term. Do not call this when the enum is unpositioned.TermsEnum.SeekStatus.END.- Specified by:
docFreqin classTermsEnum- Throws:
IOException
-
totalTermFreq
Description copied from class:TermsEnumReturns the total number of occurrences of this term across all documents (the sum of the freq() for each doc that has this term). Note that, like other term measures, this measure does not take deleted documents into account.- Specified by:
totalTermFreqin classTermsEnum- Throws:
IOException
-
seekExact
This enum does not support seeking!- Specified by:
seekExactin classTermsEnum- Returns:
- true if the term is found; return false if the enum is unpositioned.
- Throws:
UnsupportedOperationException- In general, subclasses do not support seeking.IOException
-
prepareSeekExact
This enum does not support seeking!- Specified by:
prepareSeekExactin classTermsEnum- Throws:
UnsupportedOperationException- In general, subclasses do not support seeking.IOException
-
seekCeil
This enum does not support seeking!- Specified by:
seekCeilin classTermsEnum- Throws:
UnsupportedOperationException- In general, subclasses do not support seeking.IOException
-
seekExact
This enum does not support seeking!- Specified by:
seekExactin classTermsEnum- Throws:
UnsupportedOperationException- In general, subclasses do not support seeking.IOException
-
ord
Description copied from class:TermsEnumReturns ordinal position for current term. This is an optional method (the codec may throwUnsupportedOperationException). Do not call this when the enum is unpositioned.- Specified by:
ordin classTermsEnum- Throws:
IOException
-
postings
Description copied from class:TermsEnumGetPostingsEnumfor 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.- Specified by:
postingsin classTermsEnum- Parameters:
reuse- pass a prior PostingsEnum for possible reuseflags- specifies which optional per-document values you require; seePostingsEnum.FREQS- Throws:
IOException
-
impacts
Description copied from class:TermsEnumReturn aImpactsEnum.- Specified by:
impactsin classTermsEnum- Throws:
IOException- See Also:
-
seekExact
This enum does not support seeking!- Specified by:
seekExactin classTermsEnum- Parameters:
term- the term the TermState corresponds tostate- theTermState- Throws:
UnsupportedOperationException- In general, subclasses do not support seeking.IOException
-
termState
Returns the filtered enums term state- Specified by:
termStatein classTermsEnum- Throws:
IOException- See Also:
-
next
Description copied from interface:BytesRefIteratorIncrements the iteration to the nextBytesRefin the iterator. Returns the resultingBytesRefornullif 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.- Returns:
- the next
BytesRefin the iterator ornullif the end of the iterator is reached. - Throws:
IOException- If there is a low-level I/O error.
-