## org.apache.lucene.index.memory
Class SynonymTokenFilter

    java.lang.Object
      org.apache.lucene.util.AttributeSource
          org.apache.lucene.analysis.TokenStream
              org.apache.lucene.analysis.TokenFilter
                  org.apache.lucene.index.memory.SynonymTokenFilter

    public class SynonymTokenFilter

extends TokenFilter

Injects additional tokens for synonyms of token terms fetched from the underlying child stream; the child stream must deliver lowercase tokens for synonyms to be found.

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
`AttributeSource.AttributeFactory, AttributeSource.State`

Field Summary
`static java.lang.String` `SYNONYM_TOKEN_TYPE` The Token.type used to indicate a synonym to higher level filters.

Fields inherited from class org.apache.lucene.analysis.TokenFilter
`input`

Constructor Summary
`SynonymTokenFilter(TokenStream input, SynonymMap synonyms, int maxSynonyms)` Creates an instance for the given underlying stream and synonym table.

Method Summary
`protected boolean` `createToken(java.lang.String synonym, AttributeSource.State current)` Creates and returns a token for the given synonym of the current input token; Override for custom (stateless or stateful) behavior, if desired.
`boolean` `incrementToken()` Returns the next token in the stream, or null at EOS.
`void` `reset()` Reset the filter as well as the input TokenStream.

Methods inherited from class org.apache.lucene.analysis.TokenFilter
`close, end`

Methods inherited from class org.apache.lucene.analysis.TokenStream
`getOnlyUseNewAPI, next, next, setOnlyUseNewAPI`

Methods inherited from class org.apache.lucene.util.AttributeSource
`addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, restoreState, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### SYNONYM_TOKEN_TYPE

    public static final java.lang.String SYNONYM_TOKEN_TYPE

  The Token.type used to indicate a synonym to higher level filters.

  See Also:
    Constant Field Values

Constructor Detail

### SynonymTokenFilter

    public SynonymTokenFilter(TokenStream input,
                              SynonymMap synonyms,
                              int maxSynonyms)

  Creates an instance for the given underlying stream and synonym table.

  Parameters:
    `input` - the underlying child token stream
    `synonyms` - the map used to extract synonyms for terms
    `maxSynonyms` - the maximum number of synonym tokens to return per underlying token word (a value of Integer.MAX_VALUE indicates unlimited)

Method Detail

### incrementToken

    public final boolean incrementToken()
                                 throws java.io.IOException

  Returns the next token in the stream, or null at EOS.

  Overrides:
    `incrementToken` in class `TokenStream`
  Returns:
    false for end of stream; true otherwise

    Note that this method will be defined abstract in Lucene 3.0.

  Throws:
    `java.io.IOException`

### createToken

    protected boolean createToken(java.lang.String synonym,
                                  AttributeSource.State current)

  Creates and returns a token for the given synonym of the current input token; Override for custom (stateless or stateful) behavior, if desired.

  Parameters:
    `synonym` - a synonym for the current token's term
    `current` - the current token from the underlying child stream
  Returns:
    a new token, or null to indicate that the given synonym should be ignored

### reset

    public void reset()
               throws java.io.IOException

  Description copied from class: `TokenFilter`
  Reset the filter as well as the input TokenStream.

  Overrides:
    `reset` in class `TokenFilter`
  Throws:
    `java.io.IOException`

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