Class FilteredTermsEnum

    • Field Detail

      • initialSeekTerm

        private BytesRef initialSeekTerm
      • doSeek

        private boolean doSeek
      • actualTerm

        protected BytesRef actualTerm
        Which term the enum is currently positioned to.
    • Constructor Detail

      • FilteredTermsEnum

        protected FilteredTermsEnum​(TermsEnum tenum)
        Creates a filtered TermsEnum on a terms enum.
        Parameters:
        tenum - the terms enumeration to filter.
      • FilteredTermsEnum

        protected FilteredTermsEnum​(TermsEnum tenum,
                                    boolean startWithSeek)
        Creates a filtered TermsEnum on a terms enum.
        Parameters:
        tenum - the terms enumeration to filter.
    • Method Detail

      • accept

        protected abstract FilteredTermsEnum.AcceptStatus accept​(BytesRef term)
                                                          throws java.io.IOException
        Return if term is accepted, not accepted or the iteration should ended (and possibly seek).
        Throws:
        java.io.IOException
      • nextSeekTerm

        protected BytesRef nextSeekTerm​(BytesRef currentTerm)
                                 throws java.io.IOException
        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. 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.

        Throws:
        java.io.IOException
      • term

        public BytesRef term()
                      throws java.io.IOException
        Description copied from class: TermsEnum
        Returns current term. Do not call this when the enum is unpositioned.
        Specified by:
        term in class TermsEnum
        Throws:
        java.io.IOException
      • docFreq

        public int docFreq()
                    throws java.io.IOException
        Description copied from class: TermsEnum
        Returns the number of documents containing the current term. Do not call this when the enum is unpositioned. TermsEnum.SeekStatus.END.
        Specified by:
        docFreq in class TermsEnum
        Throws:
        java.io.IOException
      • totalTermFreq

        public long totalTermFreq()
                           throws java.io.IOException
        Description copied from class: TermsEnum
        Returns 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:
        totalTermFreq in class TermsEnum
        Throws:
        java.io.IOException
      • seekExact

        public boolean seekExact​(BytesRef term)
                          throws java.io.IOException
        This enum does not support seeking!
        Specified by:
        seekExact in class TermsEnum
        Returns:
        true if the term is found; return false if the enum is unpositioned.
        Throws:
        java.lang.UnsupportedOperationException - In general, subclasses do not support seeking.
        java.io.IOException
      • seekCeil

        public TermsEnum.SeekStatus seekCeil​(BytesRef term)
                                      throws java.io.IOException
        This enum does not support seeking!
        Specified by:
        seekCeil in class TermsEnum
        Throws:
        java.lang.UnsupportedOperationException - In general, subclasses do not support seeking.
        java.io.IOException
      • seekExact

        public void seekExact​(long ord)
                       throws java.io.IOException
        This enum does not support seeking!
        Specified by:
        seekExact in class TermsEnum
        Throws:
        java.lang.UnsupportedOperationException - In general, subclasses do not support seeking.
        java.io.IOException
      • ord

        public long ord()
                 throws java.io.IOException
        Description copied from class: TermsEnum
        Returns ordinal position for current term. This is an optional method (the codec may throw UnsupportedOperationException). Do not call this when the enum is unpositioned.
        Specified by:
        ord in class TermsEnum
        Throws:
        java.io.IOException
      • postings

        public PostingsEnum postings​(PostingsEnum reuse,
                                     int flags)
                              throws java.io.IOException
        Description copied from class: TermsEnum
        Get PostingsEnum 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.

        Specified by:
        postings in class TermsEnum
        Parameters:
        reuse - pass a prior PostingsEnum for possible reuse
        flags - specifies which optional per-document values you require; see PostingsEnum.FREQS
        Throws:
        java.io.IOException
      • seekExact

        public void seekExact​(BytesRef term,
                              TermState state)
                       throws java.io.IOException
        This enum does not support seeking!
        Specified by:
        seekExact in class TermsEnum
        Parameters:
        term - the term the TermState corresponds to
        state - the TermState
        Throws:
        java.lang.UnsupportedOperationException - In general, subclasses do not support seeking.
        java.io.IOException
      • next

        public BytesRef next()
                      throws java.io.IOException
        Description copied from interface: BytesRefIterator
        Increments the iteration to the next BytesRef 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.
        Returns:
        the next BytesRef in the iterator or null if the end of the iterator is reached.
        Throws:
        java.io.IOException - If there is a low-level I/O error.