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
ATokenFilter
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 isJapaneseCompletionFilter.Mode.INDEX
.Note: This filter must be applied AFTER half-width and full-width normalization. Please ensure that a width normalizer such as
CJKWidthCharFilter
orCJKWidthFilter
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 class
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 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 newJapaneseCompletionFilter
with default configurationsJapaneseCompletionFilter(TokenStream input, JapaneseCompletionFilter.Mode mode)
Creates a newJapaneseCompletionFilter
-
Method Summary
All Methods Instance Methods Concrete Methods 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
-
-
-
-
Field Detail
-
DEFAULT_MODE
public static final JapaneseCompletionFilter.Mode DEFAULT_MODE
-
-
Constructor Detail
-
JapaneseCompletionFilter
public JapaneseCompletionFilter(TokenStream input)
Creates a newJapaneseCompletionFilter
with default configurations
-
JapaneseCompletionFilter
public JapaneseCompletionFilter(TokenStream input, JapaneseCompletionFilter.Mode mode)
Creates a newJapaneseCompletionFilter
-
-
Method Detail
-
reset
public void reset() throws IOException
- Overrides:
reset
in classTokenFilter
- Throws:
IOException
-
incrementToken
public boolean incrementToken() throws IOException
- Specified by:
incrementToken
in classTokenStream
- Throws:
IOException
-
-