Class CustomAnalyzer.Builder
- Enclosing class:
- CustomAnalyzer
CustomAnalyzer
.-
Method Summary
Modifier and TypeMethodDescriptionaddCharFilter
(Class<? extends CharFilterFactory> factory, String... params) Adds the given char filter.addCharFilter
(Class<? extends CharFilterFactory> factory, Map<String, String> params) Adds the given char filter.addCharFilter
(String name, String... params) Adds the given char filter.addCharFilter
(String name, Map<String, String> params) Adds the given char filter.addTokenFilter
(Class<? extends TokenFilterFactory> factory, String... params) Adds the given token filter.addTokenFilter
(Class<? extends TokenFilterFactory> factory, Map<String, String> params) Adds the given token filter.addTokenFilter
(String name, String... params) Adds the given token filter.addTokenFilter
(String name, Map<String, String> params) Adds the given token filter.build()
Builds the analyzer.when
(Class<? extends ConditionalTokenFilterFactory> factory, String... params) Add aConditionalTokenFilterFactory
to the analysis chainAdd aConditionalTokenFilterFactory
to the analysis chainAdd aConditionalTokenFilterFactory
to the analysis chainAdd aConditionalTokenFilterFactory
to the analysis chainwhen
(ConditionalTokenFilterFactory factory) Add aConditionalTokenFilterFactory
to the analysis chainwhenTerm
(Predicate<CharSequence> predicate) Apply subsequent token filters if the current token's term matches a predicatewithDefaultMatchVersion
(Version version) This match version is passed as default to all tokenizers or filters.withOffsetGap
(int offsetGap) Sets the offset gap of the analyzer.withPositionIncrementGap
(int posIncGap) Sets the position increment gap of the analyzer.withTokenizer
(Class<? extends TokenizerFactory> factory, String... params) Uses the given tokenizer.withTokenizer
(Class<? extends TokenizerFactory> factory, Map<String, String> params) Uses the given tokenizer.withTokenizer
(String name, String... params) Uses the given tokenizer.withTokenizer
(String name, Map<String, String> params) Uses the given tokenizer.
-
Method Details
-
withDefaultMatchVersion
This match version is passed as default to all tokenizers or filters. It is used unless you pass the parameter {code luceneMatchVersion} explicitly. It defaults to undefined, so the underlying factory will (in most cases) useVersion.LATEST
. -
withPositionIncrementGap
Sets the position increment gap of the analyzer. The default is defined in the analyzer base class.- See Also:
-
withOffsetGap
Sets the offset gap of the analyzer. The default is defined in the analyzer base class.- See Also:
-
withTokenizer
public CustomAnalyzer.Builder withTokenizer(Class<? extends TokenizerFactory> factory, String... params) throws IOException Uses the given tokenizer.- Parameters:
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.- Throws:
IOException
-
withTokenizer
public CustomAnalyzer.Builder withTokenizer(Class<? extends TokenizerFactory> factory, Map<String, String> params) throws IOExceptionUses the given tokenizer.- Parameters:
factory
- class that is used to create the tokenizer.params
- the map of parameters to be passed to factory. The map must be modifiable.- Throws:
IOException
-
withTokenizer
Uses the given tokenizer.- Parameters:
name
- is used to look up the factory withTokenizerFactory.forName(String, Map)
. The list of possible names can be looked up withTokenizerFactory.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.- Throws:
IOException
-
withTokenizer
public CustomAnalyzer.Builder withTokenizer(String name, Map<String, String> params) throws IOExceptionUses the given tokenizer.- Parameters:
name
- is used to look up the factory withTokenizerFactory.forName(String, Map)
. The list of possible names can be looked up withTokenizerFactory.availableTokenizers()
.params
- the map of parameters to be passed to factory. The map must be modifiable.- Throws:
IOException
-
addTokenFilter
public CustomAnalyzer.Builder addTokenFilter(Class<? extends TokenFilterFactory> factory, String... params) throws IOException Adds the given token filter.- Parameters:
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.- Throws:
IOException
-
addTokenFilter
public CustomAnalyzer.Builder addTokenFilter(Class<? extends TokenFilterFactory> factory, Map<String, String> params) throws IOExceptionAdds the given token filter.- Parameters:
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.- Throws:
IOException
-
addTokenFilter
Adds the given token filter.- Parameters:
name
- is used to look up the factory withTokenFilterFactory.forName(String, Map)
. The list of possible names can be looked up withTokenFilterFactory.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.- Throws:
IOException
-
addTokenFilter
public CustomAnalyzer.Builder addTokenFilter(String name, Map<String, String> params) throws IOExceptionAdds the given token filter.- Parameters:
name
- is used to look up the factory withTokenFilterFactory.forName(String, Map)
. The list of possible names can be looked up withTokenFilterFactory.availableTokenFilters()
.params
- the map of parameters to be passed to factory. The map must be modifiable.- Throws:
IOException
-
addCharFilter
public CustomAnalyzer.Builder addCharFilter(Class<? extends CharFilterFactory> factory, String... params) throws IOException Adds the given char filter.- Parameters:
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.- Throws:
IOException
-
addCharFilter
public CustomAnalyzer.Builder addCharFilter(Class<? extends CharFilterFactory> factory, Map<String, String> params) throws IOExceptionAdds the given char filter.- Parameters:
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.- Throws:
IOException
-
addCharFilter
Adds the given char filter.- Parameters:
name
- is used to look up the factory withCharFilterFactory.forName(String, Map)
. The list of possible names can be looked up withCharFilterFactory.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.- Throws:
IOException
-
addCharFilter
public CustomAnalyzer.Builder addCharFilter(String name, Map<String, String> params) throws IOExceptionAdds the given char filter.- Parameters:
name
- is used to look up the factory withCharFilterFactory.forName(String, Map)
. The list of possible names can be looked up withCharFilterFactory.availableCharFilters()
.params
- the map of parameters to be passed to factory. The map must be modifiable.- Throws:
IOException
-
when
Add aConditionalTokenFilterFactory
to the analysis chainTokenFilters 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 callCustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter chain once conditional filters have been added- Parameters:
name
- is used to look up the factory withTokenFilterFactory.forName(String, Map)
params
- the parameters to be passed to the factory- Throws:
IOException
-
when
public CustomAnalyzer.ConditionBuilder when(String name, Map<String, String> params) throws IOExceptionAdd aConditionalTokenFilterFactory
to the analysis chainTokenFilters 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 callCustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter chain once conditional filters have been added- Parameters:
name
- is used to look up the factory withTokenFilterFactory.forName(String, Map)
params
- the parameters to be passed to the factory. The map must be modifiable- Throws:
IOException
-
when
public CustomAnalyzer.ConditionBuilder when(Class<? extends ConditionalTokenFilterFactory> factory, String... params) throws IOException Add aConditionalTokenFilterFactory
to the analysis chainTokenFilters 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 callCustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter chain once conditional filters have been added- Parameters:
factory
- class that is used to create the ConditionalTokenFilterparams
- the parameters to be passed to the factory- Throws:
IOException
-
when
public CustomAnalyzer.ConditionBuilder when(Class<? extends ConditionalTokenFilterFactory> factory, Map<String, String> params) throws IOExceptionAdd aConditionalTokenFilterFactory
to the analysis chainTokenFilters 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 callCustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter chain once conditional filters have been added- Parameters:
factory
- class that is used to create the ConditionalTokenFilterparams
- the parameters to be passed to the factory. The map must be modifiable- Throws:
IOException
-
when
Add aConditionalTokenFilterFactory
to the analysis chainTokenFilters 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 callCustomAnalyzer.ConditionBuilder.endwhen()
to return to the normal tokenfilter chain once conditional filters have been added -
whenTerm
Apply subsequent token filters if the current token's term matches a predicateThis is the equivalent of:
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); } }; } }); -
build
Builds the analyzer.
-