org.apache.lucene.index

## Class AutomatonTermsEnum

- java.lang.Object
- - org.apache.lucene.index.TermsEnum
  - - org.apache.lucene.index.FilteredTermsEnum
    - - org.apache.lucene.index.AutomatonTermsEnum

- All Implemented Interfaces:
    BytesRefIterator

      public class AutomatonTermsEnum
      extends FilteredTermsEnum

  A FilteredTermsEnum that enumerates terms based upon what is accepted by a DFA.

  The algorithm is such:

  1. As long as matches are successful, keep reading sequentially.
  2. When a match fails, skip to the next string in lexicographic order that does not enter a reject state.

  The algorithm does not attempt to actually skip to the next string that is completely accepted. This is not possible when the language accepted by the FSM is not finite (i.e. * operator).

  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.index.FilteredTermsEnum

      `FilteredTermsEnum.AcceptStatus`

    - ### Nested classes/interfaces inherited from class org.apache.lucene.index.TermsEnum

      `TermsEnum.SeekStatus`

  - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.index.FilteredTermsEnum

      `actualTerm, tenum`

    - ### Fields inherited from class org.apache.lucene.index.TermsEnum

      `EMPTY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AutomatonTermsEnum(TermsEnum tenum, CompiledAutomaton compiled)` Construct an enumerator based upon an automaton, enumerating the specified field, working on a supplied TermsEnum

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected FilteredTermsEnum.AcceptStatus` | `accept(BytesRef term)` Returns true if the term matches the automaton.
    `protected BytesRef` | `nextSeekTerm(BytesRef term)` On the first call to `FilteredTermsEnum.next()` or if `FilteredTermsEnum.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.

    - ### Methods inherited from class org.apache.lucene.index.FilteredTermsEnum

      `attributes, docFreq, next, ord, postings, seekCeil, seekExact, seekExact, seekExact, setInitialSeekTerm, term, termState, totalTermFreq`

    - ### Methods inherited from class org.apache.lucene.index.TermsEnum

      `postings`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AutomatonTermsEnum

          public AutomatonTermsEnum(TermsEnum tenum,
                                    CompiledAutomaton compiled)

      Construct an enumerator based upon an automaton, enumerating the specified field, working on a supplied TermsEnum
      Parameters:
        `compiled` - CompiledAutomaton
      WARNING: This API is experimental and might change in incompatible ways in the next release.

  - ### Method Detail

    - #### accept

          protected FilteredTermsEnum.AcceptStatus accept(BytesRef term)

      Returns true if the term matches the automaton. Also stashes away the term to assist with smart enumeration.
      Specified by:
        `accept` in class `FilteredTermsEnum`

    - #### nextSeekTerm

          protected BytesRef nextSeekTerm(BytesRef term)
                                   throws IOException

      Description copied from class: `FilteredTermsEnum`
      On the first call to `FilteredTermsEnum.next()` or if `FilteredTermsEnum.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.

      Overrides:
        `nextSeekTerm` in class `FilteredTermsEnum`
      Throws:
        `IOException`

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.