Class FieldMapper.Parameter<T>

java.lang.Object
org.elasticsearch.index.mapper.FieldMapper.Parameter<T>
Type Parameters:
T - the type of the value the parameter holds
All Implemented Interfaces:
java.util.function.Supplier<T>
Enclosing class:
FieldMapper

public static final class FieldMapper.Parameter<T>
extends java.lang.Object
implements java.util.function.Supplier<T>
A configurable parameter for a field mapper
  • Field Details

    • name

      public final java.lang.String name
  • Constructor Details

    • Parameter

      public Parameter​(java.lang.String name, boolean updateable, java.util.function.Supplier<T> defaultValue, TriFunction<java.lang.String,​Mapper.TypeParser.ParserContext,​java.lang.Object,​T> parser, java.util.function.Function<FieldMapper,​T> initializer)
      Creates a new Parameter
      Parameters:
      name - the parameter name, used in parsing and serialization
      updateable - whether the parameter can be updated with a new value during a mapping update
      defaultValue - the default value for the parameter, used if unspecified in mappings
      parser - a function that converts an object to a parameter value
      initializer - a function that reads a parameter value from an existing mapper
  • Method Details

    • getValue

      public T getValue()
      Returns the current value of the parameter
    • get

      public T get()
      Specified by:
      get in interface java.util.function.Supplier<T>
    • getDefaultValue

      public T getDefaultValue()
      Returns the default value of the parameter
    • setValue

      public void setValue​(T value)
      Sets the current value of the parameter
    • isConfigured

      public boolean isConfigured()
    • acceptsNull

      public FieldMapper.Parameter<T> acceptsNull()
      Allows the parameter to accept a null value
    • addDeprecatedName

      public FieldMapper.Parameter<T> addDeprecatedName​(java.lang.String 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

      public FieldMapper.Parameter<T> deprecated()
      Deprecates the entire parameter. If this parameter is encountered during parsing, a deprecation warning will be emitted.
    • setValidator

      public FieldMapper.Parameter<T> setValidator​(java.util.function.Consumer<T> validator)
      Adds validation to a parameter, called after parsing and merging
    • setSerializer

      public FieldMapper.Parameter<T> setSerializer​(FieldMapper.Serializer<T> serializer, java.util.function.Function<T,​java.lang.String> conflictSerializer)
      Configure a custom serializer for this parameter
    • setSerializerCheck

      public FieldMapper.Parameter<T> setSerializerCheck​(FieldMapper.SerializerCheck<T> check)
      Configure a custom serialization check for this parameter
    • alwaysSerialize

      public FieldMapper.Parameter<T> alwaysSerialize()
      Always serialize this parameter, no matter its value
    • neverSerialize

      public FieldMapper.Parameter<T> neverSerialize()
      Never serialize this parameter, no matter its value
    • setMergeValidator

      public FieldMapper.Parameter<T> setMergeValidator​(FieldMapper.MergeValidator<T> mergeValidator)
      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

      public FieldMapper.Parameter<T> requiresParameters​(FieldMapper.Parameter<?>... ps)
    • precludesParameters

      public FieldMapper.Parameter<T> precludesParameters​(FieldMapper.Parameter<?>... ps)
    • toXContent

      protected void toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, boolean includeDefaults) throws java.io.IOException
      Throws:
      java.io.IOException
    • boolParam

      public static FieldMapper.Parameter<java.lang.Boolean> boolParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​java.lang.Boolean> initializer, boolean defaultValue)
      Defines a parameter that takes the values true or false
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      defaultValue - the default value, to be used if the parameter is undefined in a mapping
    • explicitBoolParam

      public static FieldMapper.Parameter<Explicit<java.lang.Boolean>> explicitBoolParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​Explicit<java.lang.Boolean>> initializer, boolean defaultValue)
      Defines a parameter that takes the values true or false, and will always serialize its value if configured.
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      defaultValue - the default value, to be used if the parameter is undefined in a mapping
    • doubleParam

      public static FieldMapper.Parameter<java.lang.Double> doubleParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​java.lang.Double> initializer, double defaultValue)
      Defines a parameter that takes a double value
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      defaultValue - the default value, to be used if the parameter is undefined in a mapping
    • floatParam

      public static FieldMapper.Parameter<java.lang.Float> floatParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​java.lang.Float> initializer, float defaultValue)
      Defines a parameter that takes a float value
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      defaultValue - the default value, to be used if the parameter is undefined in a mapping
    • intParam

      public static FieldMapper.Parameter<java.lang.Integer> intParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​java.lang.Integer> initializer, int defaultValue)
      Defines a parameter that takes an integer value
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      defaultValue - the default value, to be used if the parameter is undefined in a mapping
    • stringParam

      public static FieldMapper.Parameter<java.lang.String> stringParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​java.lang.String> initializer, java.lang.String defaultValue)
      Defines a parameter that takes a string value
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      defaultValue - the default value, to be used if the parameter is undefined in a mapping
    • stringArrayParam

      public static FieldMapper.Parameter<java.util.List<java.lang.String>> stringArrayParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​java.util.List<java.lang.String>> initializer, java.util.List<java.lang.String> defaultValue)
    • restrictedStringParam

      public static FieldMapper.Parameter<java.lang.String> restrictedStringParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​java.lang.String> initializer, java.lang.String... values)
      Defines a parameter that takes one of a restricted set of string values
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      values - 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 FieldMapper.Parameter<NamedAnalyzer> analyzerParam​(java.lang.String name, boolean updateable, java.util.function.Function<FieldMapper,​NamedAnalyzer> initializer, java.util.function.Supplier<NamedAnalyzer> defaultAnalyzer)
      Defines a parameter that takes an analyzer name
      Parameters:
      name - the parameter name
      updateable - whether the parameter can be changed by a mapping update
      initializer - a function that reads the parameter value from an existing mapper
      defaultAnalyzer - the default value, to be used if the parameter is undefined in a mapping
    • metaParam

      public static FieldMapper.Parameter<java.util.Map<java.lang.String,​java.lang.String>> metaParam()
      Declares a metadata parameter
    • boostParam

      public static FieldMapper.Parameter<java.lang.Float> boostParam()
    • indexParam

      public static FieldMapper.Parameter<java.lang.Boolean> indexParam​(java.util.function.Function<FieldMapper,​java.lang.Boolean> initializer, boolean defaultValue)
    • storeParam

      public static FieldMapper.Parameter<java.lang.Boolean> storeParam​(java.util.function.Function<FieldMapper,​java.lang.Boolean> initializer, boolean defaultValue)
    • docValuesParam

      public static FieldMapper.Parameter<java.lang.Boolean> docValuesParam​(java.util.function.Function<FieldMapper,​java.lang.Boolean> initializer, boolean defaultValue)
    • scriptParam

      public static FieldMapper.Parameter<Script> scriptParam​(java.util.function.Function<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 FieldMapper.Parameter<java.lang.String> onScriptErrorParam​(java.util.function.Function<FieldMapper,​java.lang.String> initializer, FieldMapper.Parameter<Script> dependentScriptParam)
      Defines an on_script_error parameter
      Parameters:
      initializer - retrieves the equivalent parameter from an existing FieldMapper for use in merges
      dependentScriptParam - the corresponding required script parameter
      Returns:
      a new on_error_script parameter