Class CompletionAnalyzer
java.lang.Object
org.apache.lucene.analysis.Analyzer
org.apache.lucene.analysis.AnalyzerWrapper
org.apache.lucene.search.suggest.document.CompletionAnalyzer
- All Implemented Interfaces:
Closeable,AutoCloseable
Wraps an
Analyzer to provide additional completion-only tuning
(e.g. preserving token separators, preserving position increments while converting a token stream
to an automaton)
Can be used to index SuggestField and ContextSuggestField and as a query
analyzer to PrefixCompletionQuery amd FuzzyCompletionQuery
NOTE: In most cases, index and query analyzer should have same values for preservePositionIncrements() and preserveSep()
- Since:
- 5.1.0
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.analysis.Analyzer
Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents -
Field Summary
Fields inherited from class org.apache.lucene.analysis.Analyzer
GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY -
Constructor Summary
ConstructorsConstructorDescriptionCompletionAnalyzer(Analyzer analyzer) CallsCompletionAnalyzer(org.apache.lucene.analysis.Analyzer, boolean, boolean, int)preserving token separation, position increments and no limit on graph expansionsCompletionAnalyzer(Analyzer analyzer, boolean preserveSep, boolean preservePositionIncrements) CallsCompletionAnalyzer(org.apache.lucene.analysis.Analyzer, boolean, boolean, int)with no limit on graph expansionsCompletionAnalyzer(Analyzer analyzer, boolean preserveSep, boolean preservePositionIncrements, int maxGraphExpansions) Wraps an analyzer to convert its output token stream to an automatonCompletionAnalyzer(Analyzer analyzer, int maxGraphExpansions) CallsCompletionAnalyzer(org.apache.lucene.analysis.Analyzer, boolean, boolean, int)preserving token separation and position increments -
Method Summary
Modifier and TypeMethodDescriptionprotected AnalyzergetWrappedAnalyzer(String fieldName) booleanReturns true if position increments are preserved when converting the token stream to an automatonbooleanReturns true if separation between tokens are preserved when converting the token stream to an automatonprotected Analyzer.TokenStreamComponentswrapComponents(String fieldName, Analyzer.TokenStreamComponents components) Methods inherited from class org.apache.lucene.analysis.AnalyzerWrapper
attributeFactory, createComponents, getOffsetGap, getPositionIncrementGap, initReader, initReaderForNormalization, normalize, wrapReader, wrapReaderForNormalization, wrapTokenStreamForNormalizationMethods inherited from class org.apache.lucene.analysis.Analyzer
close, getReuseStrategy, normalize, tokenStream, tokenStream
-
Constructor Details
-
CompletionAnalyzer
public CompletionAnalyzer(Analyzer analyzer, boolean preserveSep, boolean preservePositionIncrements, int maxGraphExpansions) Wraps an analyzer to convert its output token stream to an automaton- Parameters:
analyzer- token stream to be converted to an automatonpreserveSep- Preserve separation between tokens when converting to an automatonpreservePositionIncrements- Preserve position increments for tokens when converting to an automatonmaxGraphExpansions- Sets the maximum number of graph expansions of a completion automaton
-
CompletionAnalyzer
CallsCompletionAnalyzer(org.apache.lucene.analysis.Analyzer, boolean, boolean, int)preserving token separation, position increments and no limit on graph expansions -
CompletionAnalyzer
public CompletionAnalyzer(Analyzer analyzer, boolean preserveSep, boolean preservePositionIncrements) CallsCompletionAnalyzer(org.apache.lucene.analysis.Analyzer, boolean, boolean, int)with no limit on graph expansions -
CompletionAnalyzer
CallsCompletionAnalyzer(org.apache.lucene.analysis.Analyzer, boolean, boolean, int)preserving token separation and position increments
-
-
Method Details
-
preserveSep
public boolean preserveSep()Returns true if separation between tokens are preserved when converting the token stream to an automaton -
preservePositionIncrements
public boolean preservePositionIncrements()Returns true if position increments are preserved when converting the token stream to an automaton -
getWrappedAnalyzer
- Specified by:
getWrappedAnalyzerin classAnalyzerWrapper
-
wrapComponents
protected Analyzer.TokenStreamComponents wrapComponents(String fieldName, Analyzer.TokenStreamComponents components) - Overrides:
wrapComponentsin classAnalyzerWrapper
-