Package org.elasticsearch.index.mapper
Class FieldMapper.Parameter<T>
org.elasticsearch.index.mapper.FieldMapper.Parameter<T>
- Type Parameters:
T
- the type of the value the parameter holds
- All Implemented Interfaces:
<T>
- Enclosing class:
- FieldMapper
public static final class FieldMapper.Parameter<T>
extends
implements <T>
A configurable parameter for a field mapper
-
Field Summary
-
Constructor Summary
ConstructorDescriptionname, boolean updateable, <T> defaultValue, ,,T> parser, <FieldMapper,T> initializer)
Creates a new Parameter -
Method Summary
Modifier and TypeMethodDescriptionAllows the parameter to accept anull
valuedeprecatedName)
Adds a deprecated parameter name.Always serialize this parameter, no matter its valuestatic FieldMapper.Parameter<NamedAnalyzer>
name, boolean updateable, <FieldMapper,NamedAnalyzer> initializer, <NamedAnalyzer> defaultAnalyzer)
Defines a parameter that takes an analyzer namestatic >
name, boolean updateable, <> initializer, boolean defaultValue)
Defines a parameter that takes the valuestrue
orfalse
static >
boolean
Deprecates the entire parameter.static >
<> initializer, boolean defaultValue)
static >
name, boolean updateable, <> initializer, double defaultValue)
Defines a parameter that takes a double valuestatic >>
name, boolean updateable, <>> initializer, boolean defaultValue)
Defines a parameter that takes the valuestrue
orfalse
, and will always serialize its value if configured.static >
name, boolean updateable, <> initializer, float defaultValue)
Defines a parameter that takes a float valueget()
Returns the default value of the parametergetValue()
Returns the current value of the parameterstatic >
<> initializer, boolean defaultValue)
static >
name, boolean updateable, <> initializer, int defaultValue)
Defines a parameter that takes an integer valueboolean
static <,>>
Declares a metadata parameterNever serialize this parameter, no matter its valuestatic >
<> initializer, FieldMapper.Parameter<Script> dependentScriptParam)
Defines an on_script_error parametervoid
field, MappingParserContext context, in)
Parse the field value from an ObjectprecludesParameters(FieldMapper.Parameter<?>... ps)
requiresParameters(FieldMapper.Parameter<?>... ps)
static >
name, boolean updateable, <> initializer, ... values)
Defines a parameter that takes one of a restricted set of string valuesstatic FieldMapper.Parameter<Script>
<FieldMapper,Script> initializer)
Defines a script parametersetMergeValidator(FieldMapper.MergeValidator<T> mergeValidator)
Sets a custom merge validator.setSerializer(FieldMapper.Serializer<T> serializer, <> conflictSerializer)
Configure a custom serializer for this parameterConfigure a custom serialization check for this parameter<T> validator)
Adds validation to a parameter, called after parsing and mergingvoid
Sets the current value of the parameterstatic >
<> initializer, boolean defaultValue)
static <>>
name, boolean updateable, <<>> initializer, <> defaultValue)
static >
name, boolean updateable, <> initializer, defaultValue)
Defines a parameter that takes a string valueprotected void
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, boolean includeDefaults)
Methods inherited from class java.lang.
, , , , , , , , , ,
-
Field Details
-
name
public final name
-
-
Constructor Details
-
Parameter
public Parameter( name, boolean updateable, <T> defaultValue, ,,T> parser, <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
- Specified by:
in interface
<T>
-
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 -
canAcceptNull
public boolean canAcceptNull() -
addDeprecatedName
public deprecatedName)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. -
deprecated
Deprecates the entire parameter. If this parameter is encountered during parsing, a deprecation warning will be emitted. -
setValidator
public <T> validator)Adds validation to a parameter, called after parsing and merging -
setSerializer
public FieldMapper.Parameter<T> setSerializer(FieldMapper.Serializer<T> serializer, <> conflictSerializer)Configure a custom serializer for this parameter -
setSerializerCheck
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 -
requiresParameters
-
precludesParameters
-
parse
Parse the field value from an Object- Parameters:
field
- the field namecontext
- the parser contextin
- the object
-
toXContent
protected void toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, boolean includeDefaults) throws- Throws:
-
boolParam
public static > boolParam( name, boolean updateable, <> 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 >> explicitBoolParam( name, boolean updateable, <>> 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 > doubleParam( name, boolean updateable, <> 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 > floatParam( name, boolean updateable, <> 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 > intParam( name, boolean updateable, <> 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 > stringParam( name, boolean updateable, <> initializer, 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 <>> stringArrayParam( name, boolean updateable, <<>> initializer, <> defaultValue) -
restrictedStringParam
public static > restrictedStringParam( name, boolean updateable, <> initializer, ... 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 name, boolean updateable, <FieldMapper,NamedAnalyzer> initializer, <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
public static <,>> metaParam()Declares a metadata parameter -
boostParam
public static > boostParam() -
indexParam
public static > indexParam(<> initializer, boolean defaultValue) -
storeParam
public static > storeParam(<> initializer, boolean defaultValue) -
docValuesParam
public static > docValuesParam(<> initializer, boolean defaultValue) -
scriptParam
public static <FieldMapper,Script> initializer)Defines a script parameter- Parameters:
initializer
- retrieves the equivalent parameter from an existing FieldMapper for use in merges- Returns:
- a script parameter
-
onScriptErrorParam
public static > onScriptErrorParam(<> initializer, FieldMapper.Parameter<Script> dependentScriptParam)Defines an on_script_error parameter- Parameters:
initializer
- retrieves the equivalent parameter from an existing FieldMapper for use in mergesdependentScriptParam
- the corresponding required script parameter- Returns:
- a new on_error_script parameter
-