JapaneseCompletionFilter (Lucene 10.5.0 kuromoji API)
Description: declaration: package: org.apache.lucene.analysis.ja, class: JapaneseCompletionFilter

Package org.apache.lucene.analysis.ja

# Class JapaneseCompletionFilter

java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.TokenFilter
org.apache.lucene.analysis.ja.JapaneseCompletionFilter

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `Unwrappable<TokenStream>`

public final class JapaneseCompletionFilter extends TokenFilter
A `TokenFilter` that adds Japanese romanized tokens to the term attribute. Also, this keeps original tokens (surface forms). Main usage of this filter is Query Auto-Completion.

Supported romanization systems: (modified) Hepburn-shiki, Kunrei-shiki (Nihon-shiki) and Wāpuro shiki.

This does not strictly comply with the romanization systems listed above, but tries to cover possible keystroke supported by various Input Methods. e.g.: Circumflex / Macron representing Chōonpu (長音符) are not supported.

The romanization behaviour changes according to its `JapaneseCompletionFilter.Mode`. The default mode is `JapaneseCompletionFilter.Mode.INDEX`.

Note: This filter must be applied AFTER half-width and full-width normalization. Please ensure that a width normalizer such as `CJKWidthCharFilter` or `CJKWidthFilter` is included in your analysis chain. IF THE WIDTH NORMALIZATION IS NOT PERFORMED, THIS DOES NOT WORK AS EXPECTED. See also: `JapaneseCompletionAnalyzer`.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `JapaneseCompletionFilter.Mode`
  Completion mode

  ## Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource

  `AttributeSource.State`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final JapaneseCompletionFilter.Mode`
  `DEFAULT_MODE`

  ### Fields inherited from class org.apache.lucene.analysis.TokenFilter

  `input`

  ### Fields inherited from class org.apache.lucene.analysis.TokenStream

  `DEFAULT_TOKEN_ATTRIBUTE_FACTORY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JapaneseCompletionFilter(TokenStream input)`
  Creates a new `JapaneseCompletionFilter` with default configurations
  `JapaneseCompletionFilter(TokenStream input, JapaneseCompletionFilter.Mode mode)`
  Creates a new `JapaneseCompletionFilter`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `incrementToken()`
  `void`
  `reset()`

  ### Methods inherited from class org.apache.lucene.analysis.TokenFilter

  `close, end, unwrap`

  ### Methods inherited from class org.apache.lucene.util.AttributeSource

  `addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toString`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### DEFAULT_MODE

    public static final JapaneseCompletionFilter.Mode DEFAULT_MODE

- ## Constructor Details

  - ### JapaneseCompletionFilter

    public JapaneseCompletionFilter(TokenStream input)
    Creates a new `JapaneseCompletionFilter` with default configurations

  - ### JapaneseCompletionFilter

    public JapaneseCompletionFilter(TokenStream input, JapaneseCompletionFilter.Mode mode)
    Creates a new `JapaneseCompletionFilter`

- ## Method Details

  - ### reset

    public void reset() throws IOException
    Overrides:
      `reset` in class `TokenFilter`
    Throws:
      `IOException`

  - ### incrementToken

    public boolean incrementToken() throws IOException
    Specified by:
      `incrementToken` in class `TokenStream`
    Throws:
      `IOException`