diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java index ae088d5fed02e..46c3a478a33a5 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java @@ -136,8 +136,8 @@ public Builder(String name, boolean ignoreMalformedByDefault, boolean coerceByDe this.metric = TimeSeriesParams.metricParam( m -> toType(m).metricType, - TimeSeriesParams.MetricType.gauge, - TimeSeriesParams.MetricType.counter + TimeSeriesParams.MetricType.GAUGE, + TimeSeriesParams.MetricType.COUNTER ).addValidator(v -> { if (v != null && hasDocValues.getValue() == false) { throw new IllegalArgumentException( @@ -287,7 +287,7 @@ public IndexFieldData.Builder fielddataBuilder(FieldDataContext fieldDataContext failIfNoDocValues(); } - ValuesSourceType valuesSourceType = metricType == TimeSeriesParams.MetricType.counter + ValuesSourceType valuesSourceType = metricType == TimeSeriesParams.MetricType.COUNTER ? TimeSeriesValuesSourceType.COUNTER : IndexNumericFieldData.NumericType.LONG.getValuesSourceType(); if ((operation == FielddataOperation.SEARCH || operation == FielddataOperation.SCRIPT) && hasDocValues()) { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java index 6656e0aa1f936..d1089fec66931 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java @@ -110,7 +110,7 @@ public void setUp() throws Exception { .endObject() .startObject("some_metric") .field("type", "long") - .field("time_series_metric", TimeSeriesParams.MetricType.counter) + .field("time_series_metric", TimeSeriesParams.MetricType.COUNTER) .endObject() .startObject("secret_soundtrack") .field("type", "alias") @@ -153,7 +153,7 @@ public void setUp() throws Exception { .endObject() .startObject("some_metric") .field("type", "long") - .field("time_series_metric", TimeSeriesParams.MetricType.gauge) + .field("time_series_metric", TimeSeriesParams.MetricType.GAUGE) .endObject() .endObject() .endObject() @@ -368,7 +368,7 @@ public void testFieldMetricsAndDimensions() { assertTrue(response.get().get("some_dimension").get("keyword").isDimension()); assertNull(response.get().get("some_dimension").get("keyword").nonDimensionIndices()); assertTrue(response.get().containsKey("some_metric")); - assertEquals(TimeSeriesParams.MetricType.counter, response.get().get("some_metric").get("long").getMetricType()); + assertEquals(TimeSeriesParams.MetricType.COUNTER, response.get().get("some_metric").get("long").getMetricType()); assertNull(response.get().get("some_metric").get("long").metricConflictsIndices()); response = client().prepareFieldCaps("old_index", "new_index").setFields("some_dimension", "some_metric").get(); diff --git a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java index eec23999dedca..9888240021c37 100644 --- a/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java +++ b/server/src/main/java/org/elasticsearch/action/fieldcaps/FieldCapabilities.java @@ -211,7 +211,7 @@ public FieldCapabilities( isSearchable, isAggregatable, isDimension == null ? false : isDimension, - metricType != null ? Enum.valueOf(TimeSeriesParams.MetricType.class, metricType) : null, + metricType != null ? TimeSeriesParams.MetricType.fromString(metricType) : null, indices != null ? indices.toArray(new String[0]) : null, nonSearchableIndices != null ? nonSearchableIndices.toArray(new String[0]) : null, nonAggregatableIndices != null ? nonAggregatableIndices.toArray(new String[0]) : null, diff --git a/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java index a6db9824c756f..c481efeb3a23b 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java @@ -163,7 +163,7 @@ protected AbstractGeometryFieldMapper( MultiFields multiFields, CopyTo copyTo, Parser parser, - String onScriptError + OnScriptError onScriptError ) { super(simpleName, mappedFieldType, multiFields, copyTo, true, onScriptError); this.ignoreMalformed = Explicit.EXPLICIT_FALSE; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java index 571f0d59a9f20..14db646d86849 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/AbstractPointGeometryFieldMapper.java @@ -54,7 +54,7 @@ protected AbstractPointGeometryFieldMapper( MultiFields multiFields, CopyTo copyTo, Parser parser, - String onScriptError + OnScriptError onScriptError ) { super(simpleName, mappedFieldType, multiFields, copyTo, parser, onScriptError); this.nullValue = null; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/AbstractScriptFieldType.java b/server/src/main/java/org/elasticsearch/index/mapper/AbstractScriptFieldType.java index 684adb9ac124a..b84294168397c 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/AbstractScriptFieldType.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/AbstractScriptFieldType.java @@ -225,7 +225,10 @@ abstract static class Builder extends RuntimeField.Builder { Objects::toString ).setSerializerCheck((id, ic, v) -> ic); - private final FieldMapper.Parameter onScriptError = FieldMapper.Parameter.onScriptErrorParam(m -> m.onScriptError, script); + private final FieldMapper.Parameter onScriptError = FieldMapper.Parameter.onScriptErrorParam( + m -> m.onScriptError, + script + ); Builder(String name, ScriptContext scriptContext) { super(name); @@ -270,14 +273,7 @@ final RuntimeField createRuntimeField(Factory scriptFactory) { } final RuntimeField createRuntimeField(Factory scriptFactory, Version indexVersion) { - var fieldType = createFieldType( - name, - scriptFactory, - getScript(), - meta(), - indexVersion, - OnScriptError.fromString(onScriptError.get()) - ); + var fieldType = createFieldType(name, scriptFactory, getScript(), meta(), indexVersion, onScriptError.get()); return new LeafRuntimeField(name, fieldType, getParameters()); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java index b69d698f0f38f..63d9fe5c6b2b2 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java @@ -96,7 +96,7 @@ public static class Builder extends FieldMapper.Builder { ).acceptsNull(); private final Parameter