public static final class CustomAnalyzer.Builder extends Object
CustomAnalyzer
.Modifier and Type | Method and Description |
---|---|
CustomAnalyzer.Builder |
addCharFilter(Class<? extends CharFilterFactory> factory,
Map<String,String> params)
Adds the given char filter.
|
CustomAnalyzer.Builder |
addCharFilter(Class<? extends CharFilterFactory> factory,
String... params)
Adds the given char filter.
|
CustomAnalyzer.Builder |
addCharFilter(String name,
Map<String,String> params)
Adds the given char filter.
|
CustomAnalyzer.Builder |
addCharFilter(String name,
String... params)
Adds the given char filter.
|
CustomAnalyzer.Builder |
addTokenFilter(Class<? extends TokenFilterFactory> factory,
Map<String,String> params)
Adds the given token filter.
|
CustomAnalyzer.Builder |
addTokenFilter(Class<? extends TokenFilterFactory> factory,
String... params)
Adds the given token filter.
|
CustomAnalyzer.Builder |
addTokenFilter(String name,
Map<String,String> params)
Adds the given token filter.
|
CustomAnalyzer.Builder |
addTokenFilter(String name,
String... params)
Adds the given token filter.
|
CustomAnalyzer |
build()
Builds the analyzer.
|
CustomAnalyzer.ConditionBuilder |
when(Class<? extends ConditionalTokenFilterFactory> factory,
Map<String,String> params)
Add a
ConditionalTokenFilterFactory to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. |
CustomAnalyzer.ConditionBuilder |
when(Class<? extends ConditionalTokenFilterFactory> factory,
String... params)
Add a
ConditionalTokenFilterFactory to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. |
CustomAnalyzer.ConditionBuilder |
when(ConditionalTokenFilterFactory factory)
Add a
ConditionalTokenFilterFactory to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. |
CustomAnalyzer.ConditionBuilder |
when(String name,
Map<String,String> params)
Add a
ConditionalTokenFilterFactory to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. |
CustomAnalyzer.ConditionBuilder |
when(String name,
String... params)
Add a
ConditionalTokenFilterFactory to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. |
CustomAnalyzer.ConditionBuilder |
whenTerm(Predicate<CharSequence> predicate)
Apply subsequent token filters if the current token's term matches a predicate
This is the equivalent of:
|
CustomAnalyzer.Builder |
withDefaultMatchVersion(Version version)
This match version is passed as default to all tokenizers or filters.
|
CustomAnalyzer.Builder |
withOffsetGap(int offsetGap)
Sets the offset gap of the analyzer.
|
CustomAnalyzer.Builder |
withPositionIncrementGap(int posIncGap)
Sets the position increment gap of the analyzer.
|
CustomAnalyzer.Builder |
withTokenizer(Class<? extends TokenizerFactory> factory,
Map<String,String> params)
Uses the given tokenizer.
|
CustomAnalyzer.Builder |
withTokenizer(Class<? extends TokenizerFactory> factory,
String... params)
Uses the given tokenizer.
|
CustomAnalyzer.Builder |
withTokenizer(String name,
Map<String,String> params)
Uses the given tokenizer.
|
CustomAnalyzer.Builder |
withTokenizer(String name,
String... params)
Uses the given tokenizer.
|
public CustomAnalyzer.Builder withDefaultMatchVersion(Version version)
Version.LATEST
.public CustomAnalyzer.Builder withPositionIncrementGap(int posIncGap)
Analyzer.getPositionIncrementGap(String)
public CustomAnalyzer.Builder withOffsetGap(int offsetGap)
Analyzer.getOffsetGap(String)
public CustomAnalyzer.Builder withTokenizer(Class<? extends TokenizerFactory> factory, String... params) throws IOException
factory
- class that is used to create the tokenizer.params
- a list of factory string params as key/value pairs.
The number of parameters must be an even number, as they are pairs.IOException
public CustomAnalyzer.Builder withTokenizer(Class<? extends TokenizerFactory> factory, Map<String,String> params) throws IOException
factory
- class that is used to create the tokenizer.params
- the map of parameters to be passed to factory. The map must be modifiable.IOException
public CustomAnalyzer.Builder withTokenizer(String name, String... params) throws IOException
name
- is used to look up the factory with TokenizerFactory.forName(String, Map)
.
The list of possible names can be looked up with TokenizerFactory.availableTokenizers()
.params
- a list of factory string params as key/value pairs.
The number of parameters must be an even number, as they are pairs.IOException
public CustomAnalyzer.Builder withTokenizer(String name, Map<String,String> params) throws IOException
name
- is used to look up the factory with TokenizerFactory.forName(String, Map)
.
The list of possible names can be looked up with TokenizerFactory.availableTokenizers()
.params
- the map of parameters to be passed to factory. The map must be modifiable.IOException
public CustomAnalyzer.Builder addTokenFilter(Class<? extends TokenFilterFactory> factory, String... params) throws IOException
factory
- class that is used to create the token filter.params
- a list of factory string params as key/value pairs.
The number of parameters must be an even number, as they are pairs.IOException
public CustomAnalyzer.Builder addTokenFilter(Class<? extends TokenFilterFactory> factory, Map<String,String> params) throws IOException
factory
- class that is used to create the token filter.params
- the map of parameters to be passed to factory. The map must be modifiable.IOException
public CustomAnalyzer.Builder addTokenFilter(String name, String... params) throws IOException
name
- is used to look up the factory with TokenFilterFactory.forName(String, Map)
.
The list of possible names can be looked up with TokenFilterFactory.availableTokenFilters()
.params
- a list of factory string params as key/value pairs.
The number of parameters must be an even number, as they are pairs.IOException
public CustomAnalyzer.Builder addTokenFilter(String name, Map<String,String> params) throws IOException
name
- is used to look up the factory with TokenFilterFactory.forName(String, Map)
.
The list of possible names can be looked up with TokenFilterFactory.availableTokenFilters()
.params
- the map of parameters to be passed to factory. The map must be modifiable.IOException
public CustomAnalyzer.Builder addCharFilter(Class<? extends CharFilterFactory> factory, String... params) throws IOException
factory
- class that is used to create the char filter.params
- a list of factory string params as key/value pairs.
The number of parameters must be an even number, as they are pairs.IOException
public CustomAnalyzer.Builder addCharFilter(Class<? extends CharFilterFactory> factory, Map<String,String> params) throws IOException
factory
- class that is used to create the char filter.params
- the map of parameters to be passed to factory. The map must be modifiable.IOException
public CustomAnalyzer.Builder addCharFilter(String name, String... params) throws IOException
name
- is used to look up the factory with CharFilterFactory.forName(String, Map)
.
The list of possible names can be looked up with CharFilterFactory.availableCharFilters()
.params
- a list of factory string params as key/value pairs.
The number of parameters must be an even number, as they are pairs.IOException
public CustomAnalyzer.Builder addCharFilter(String name, Map<String,String> params) throws IOException
name
- is used to look up the factory with CharFilterFactory.forName(String, Map)
.
The list of possible names can be looked up with CharFilterFactory.availableCharFilters()
.params
- the map of parameters to be passed to factory. The map must be modifiable.IOException
public CustomAnalyzer.ConditionBuilder when(String name, String... params) throws IOException
ConditionalTokenFilterFactory
to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. Consumers
must call CustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter
chain once conditional filters have been addedname
- is used to look up the factory with TokenFilterFactory.forName(String, Map)
params
- the parameters to be passed to the factoryIOException
public CustomAnalyzer.ConditionBuilder when(String name, Map<String,String> params) throws IOException
ConditionalTokenFilterFactory
to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. Consumers
must call CustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter
chain once conditional filters have been addedname
- is used to look up the factory with TokenFilterFactory.forName(String, Map)
params
- the parameters to be passed to the factory. The map must be modifiableIOException
public CustomAnalyzer.ConditionBuilder when(Class<? extends ConditionalTokenFilterFactory> factory, String... params) throws IOException
ConditionalTokenFilterFactory
to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. Consumers
must call CustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter
chain once conditional filters have been addedfactory
- class that is used to create the ConditionalTokenFilterparams
- the parameters to be passed to the factoryIOException
public CustomAnalyzer.ConditionBuilder when(Class<? extends ConditionalTokenFilterFactory> factory, Map<String,String> params) throws IOException
ConditionalTokenFilterFactory
to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. Consumers
must call CustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter
chain once conditional filters have been addedfactory
- class that is used to create the ConditionalTokenFilterparams
- the parameters to be passed to the factory. The map must be modifiableIOException
public CustomAnalyzer.ConditionBuilder when(ConditionalTokenFilterFactory factory)
ConditionalTokenFilterFactory
to the analysis chain
TokenFilters added by subsequent calls to CustomAnalyzer.ConditionBuilder.addTokenFilter(String, String...)
and related functions will only be used if the current token matches the condition. Consumers
must call CustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter
chain once conditional filters have been addedpublic CustomAnalyzer.ConditionBuilder whenTerm(Predicate<CharSequence> predicate)
when(new ConditionalTokenFilterFactory(Collections.emptyMap()) {@
Override protected ConditionalTokenFilter create(TokenStream input, Function<TokenStream, TokenStream> inner) { return new ConditionalTokenFilter(input, inner) { CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);@
Override protected boolean shouldFilter() { return predicate.test(termAtt); } }; } });
public CustomAnalyzer build()
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.