From 7a2b70b9c33b064feedbce2aa5b7131b9f8a8b83 Mon Sep 17 00:00:00 2001 From: carlosdelest Date: Fri, 5 Apr 2024 14:24:14 +0200 Subject: [PATCH] PR Review comments --- .../java/org/elasticsearch/TransportVersions.java | 2 +- .../cluster/metadata/IndexMetadata.java | 14 +++++++------- .../index/mapper/InferenceFieldMapper.java | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index 95e3353de4120..10f80ae739fdf 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -163,7 +163,7 @@ static TransportVersion def(int id) { public static final TransportVersion CCR_STATS_API_TIMEOUT_PARAM = def(8_622_00_0); public static final TransportVersion ESQL_ORDINAL_BLOCK = def(8_623_00_0); public static final TransportVersion ML_INFERENCE_COHERE_RERANK = def(8_624_00_0); - public static final TransportVersion SEMANTIC_TEXT_FIELD_ADDED = def(8_625_00_0); + public static final TransportVersion INFERENCE_FIELDS_METADATA = def(8_625_00_0); /* * STOP! READ THIS FIRST! No, really, diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index b66da654f8a1c..529814e83ba38 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -540,7 +540,7 @@ public Iterator> settings() { public static final String KEY_SHARD_SIZE_FORECAST = "shard_size_forecast"; - public static final String KEY_FIELD_INFERENCE = "field_inference"; + public static final String KEY_INFERENCE_FIELDS = "field_inference"; public static final String INDEX_STATE_FILE_PREFIX = "state-"; @@ -1569,7 +1569,7 @@ private static class IndexMetadataDiff implements Diff { } primaryTerms = in.readVLongArray(); mappings = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), MAPPING_DIFF_VALUE_READER); - if (in.getTransportVersion().onOrAfter(TransportVersions.SEMANTIC_TEXT_FIELD_ADDED)) { + if (in.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_FIELDS_METADATA)) { inferenceFields = DiffableUtils.readImmutableOpenMapDiff( in, DiffableUtils.getStringKeySerializer(), @@ -1627,7 +1627,7 @@ public void writeTo(StreamOutput out) throws IOException { } out.writeVLongArray(primaryTerms); mappings.writeTo(out); - if (out.getTransportVersion().onOrAfter(TransportVersions.SEMANTIC_TEXT_FIELD_ADDED)) { + if (out.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_FIELDS_METADATA)) { inferenceFields.writeTo(out); } aliases.writeTo(out); @@ -1709,7 +1709,7 @@ public static IndexMetadata readFrom(StreamInput in, @Nullable Function builder.putInferenceField(f)); } @@ -1773,7 +1773,7 @@ public void writeTo(StreamOutput out, boolean mappingsAsHash) throws IOException mapping.writeTo(out); } } - if (out.getTransportVersion().onOrAfter(TransportVersions.SEMANTIC_TEXT_FIELD_ADDED)) { + if (out.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_FIELDS_METADATA)) { out.writeCollection(inferenceFields.values()); } out.writeCollection(aliases.values()); @@ -2437,7 +2437,7 @@ public static void toXContent(IndexMetadata indexMetadata, XContentBuilder build } if (indexMetadata.getInferenceFields().isEmpty() == false) { - builder.startObject(KEY_FIELD_INFERENCE); + builder.startObject(KEY_INFERENCE_FIELDS); for (InferenceFieldMetadata field : indexMetadata.getInferenceFields().values()) { field.toXContent(builder, params); } @@ -2521,7 +2521,7 @@ public static IndexMetadata fromXContent(XContentParser parser, Map