Package org.opensearch.index.mapper
Class ParametrizedFieldMapper.Parameter<T>
java.lang.Object
org.opensearch.index.mapper.ParametrizedFieldMapper.Parameter<T>
- Type Parameters:
T
- the type of the value the parameter holds
- All Implemented Interfaces:
Supplier<T>
- Enclosing class:
ParametrizedFieldMapper
@PublicApi(since="1.0.0")
public static final class ParametrizedFieldMapper.Parameter<T>
extends Object
implements Supplier<T>
A configurable parameter for a field mapper
- Opensearch.api:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAllows the parameter to accept anull
valueaddDeprecatedName
(String deprecatedName) Adds a deprecated parameter name.Always serialize this parameter, no matter its valueanalyzerParam
(String name, boolean updateable, Function<FieldMapper, NamedAnalyzer> initializer, Supplier<NamedAnalyzer> defaultAnalyzer) Defines a parameter that takes an analyzer nameboolParam
(String name, boolean updateable, Function<FieldMapper, Boolean> initializer, boolean defaultValue) Defines a parameter that takes the valuestrue
orfalse
docValuesParam
(Function<FieldMapper, Boolean> initializer, boolean defaultValue) doubleParam
(String name, boolean updateable, Function<FieldMapper, Double> initializer, double defaultValue) Defines a parameter that takes a double valuestatic ParametrizedFieldMapper.Parameter
<org.opensearch.common.Explicit<Boolean>> explicitBoolParam
(String name, boolean updateable, Function<FieldMapper, org.opensearch.common.Explicit<Boolean>> initializer, boolean defaultValue) Defines a parameter that takes the valuestrue
orfalse
, and will always serialize its value if configured.floatParam
(String name, boolean updateable, Function<FieldMapper, Float> initializer, float defaultValue) Defines a parameter that takes a float valueget()
Returns the default value of the parametergetValue()
Returns the current value of the parameterindexParam
(Function<FieldMapper, Boolean> initializer, boolean defaultValue) intParam
(String name, boolean updateable, Function<FieldMapper, Integer> initializer, int defaultValue) Defines a parameter that takes an integer valueboolean
static ParametrizedFieldMapper.Parameter
<Map<String, String>> Declares a metadata parameterNever serialize this parameter, no matter its valuerestrictedStringParam
(String name, boolean updateable, Function<FieldMapper, String> initializer, String... values) Defines a parameter that takes one of a restricted set of string valuessetMergeValidator
(BiPredicate<T, T> mergeValidator) Sets a custom merge validator.setSerializer
(ParametrizedFieldMapper.Serializer<T> serializer, Function<T, String> conflictSerializer) Configure a custom serializer for this parameterConfigure a custom serialization check for this parametersetValidator
(Consumer<T> validator) Adds validation to a parameter, called after parsing and mergingvoid
Sets the current value of the parameterstoreParam
(Function<FieldMapper, Boolean> initializer, boolean defaultValue) static ParametrizedFieldMapper.Parameter
<List<String>> stringArrayParam
(String name, boolean updateable, Function<FieldMapper, List<String>> initializer, List<String> defaultValue) stringParam
(String name, boolean updateable, Function<FieldMapper, String> initializer, String defaultValue) Defines a parameter that takes a string valueprotected void
toXContent
(org.opensearch.core.xcontent.XContentBuilder builder, boolean includeDefaults)
-
Field Details
-
name
-
-
Constructor Details
-
Parameter
public Parameter(String name, boolean updateable, Supplier<T> defaultValue, org.opensearch.common.TriFunction<String, Mapper.TypeParser.ParserContext, Object, T> parser, Function<FieldMapper, T> initializer) Creates a new Parameter- Parameters:
name
- the parameter name, used in parsing and serializationupdateable
- whether the parameter can be updated with a new value during a mapping updatedefaultValue
- the default value for the parameter, used if unspecified in mappingsparser
- a function that converts an object to a parameter valueinitializer
- a function that reads a parameter value from an existing mapper
-
-
Method Details
-
getValue
Returns the current value of the parameter -
get
-
getDefaultValue
Returns the default value of the parameter -
setValue
Sets the current value of the parameter -
isConfigured
public boolean isConfigured() -
acceptsNull
Allows the parameter to accept anull
value -
addDeprecatedName
Adds a deprecated parameter name.If this parameter name is encountered during parsing, a deprecation warning will be emitted. The parameter will be serialized with its main name.
-
setValidator
Adds validation to a parameter, called after parsing and merging -
setSerializer
public ParametrizedFieldMapper.Parameter<T> setSerializer(ParametrizedFieldMapper.Serializer<T> serializer, Function<T, String> conflictSerializer) Configure a custom serializer for this parameter -
setSerializerCheck
public ParametrizedFieldMapper.Parameter<T> setSerializerCheck(ParametrizedFieldMapper.SerializerCheck<T> check) Configure a custom serialization check for this parameter -
alwaysSerialize
Always serialize this parameter, no matter its value -
neverSerialize
Never serialize this parameter, no matter its value -
setMergeValidator
Sets a custom merge validator. By default, merges are accepted if the parameter is updateable, or if the previous and new values are equal -
toXContent
protected void toXContent(org.opensearch.core.xcontent.XContentBuilder builder, boolean includeDefaults) throws IOException - Throws:
IOException
-
boolParam
public static ParametrizedFieldMapper.Parameter<Boolean> boolParam(String name, boolean updateable, Function<FieldMapper, Boolean> initializer, boolean defaultValue) Defines a parameter that takes the valuestrue
orfalse
- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mapperdefaultValue
- the default value, to be used if the parameter is undefined in a mapping
-
explicitBoolParam
public static ParametrizedFieldMapper.Parameter<org.opensearch.common.Explicit<Boolean>> explicitBoolParam(String name, boolean updateable, Function<FieldMapper, org.opensearch.common.Explicit<Boolean>> initializer, boolean defaultValue) Defines a parameter that takes the valuestrue
orfalse
, and will always serialize its value if configured.- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mapperdefaultValue
- the default value, to be used if the parameter is undefined in a mapping
-
doubleParam
public static ParametrizedFieldMapper.Parameter<Double> doubleParam(String name, boolean updateable, Function<FieldMapper, Double> initializer, double defaultValue) Defines a parameter that takes a double value- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mapperdefaultValue
- the default value, to be used if the parameter is undefined in a mapping
-
floatParam
public static ParametrizedFieldMapper.Parameter<Float> floatParam(String name, boolean updateable, Function<FieldMapper, Float> initializer, float defaultValue) Defines a parameter that takes a float value- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mapperdefaultValue
- the default value, to be used if the parameter is undefined in a mapping
-
intParam
public static ParametrizedFieldMapper.Parameter<Integer> intParam(String name, boolean updateable, Function<FieldMapper, Integer> initializer, int defaultValue) Defines a parameter that takes an integer value- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mapperdefaultValue
- the default value, to be used if the parameter is undefined in a mapping
-
stringParam
public static ParametrizedFieldMapper.Parameter<String> stringParam(String name, boolean updateable, Function<FieldMapper, String> initializer, String defaultValue) Defines a parameter that takes a string value- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mapperdefaultValue
- the default value, to be used if the parameter is undefined in a mapping
-
stringArrayParam
public static ParametrizedFieldMapper.Parameter<List<String>> stringArrayParam(String name, boolean updateable, Function<FieldMapper, List<String>> initializer, List<String> defaultValue) -
restrictedStringParam
public static ParametrizedFieldMapper.Parameter<String> restrictedStringParam(String name, boolean updateable, Function<FieldMapper, String> initializer, String... values) Defines a parameter that takes one of a restricted set of string values- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mappervalues
- the set of values that the parameter can take. The first value in the list is the default value, to be used if the parameter is undefined in a mapping
-
analyzerParam
public static ParametrizedFieldMapper.Parameter<NamedAnalyzer> analyzerParam(String name, boolean updateable, Function<FieldMapper, NamedAnalyzer> initializer, Supplier<NamedAnalyzer> defaultAnalyzer) Defines a parameter that takes an analyzer name- Parameters:
name
- the parameter nameupdateable
- whether the parameter can be changed by a mapping updateinitializer
- a function that reads the parameter value from an existing mapperdefaultAnalyzer
- the default value, to be used if the parameter is undefined in a mapping
-
metaParam
Declares a metadata parameter -
indexParam
public static ParametrizedFieldMapper.Parameter<Boolean> indexParam(Function<FieldMapper, Boolean> initializer, boolean defaultValue) -
storeParam
public static ParametrizedFieldMapper.Parameter<Boolean> storeParam(Function<FieldMapper, Boolean> initializer, boolean defaultValue) -
docValuesParam
public static ParametrizedFieldMapper.Parameter<Boolean> docValuesParam(Function<FieldMapper, Boolean> initializer, boolean defaultValue) -
boostParam
-