Skip to content

Commit

Permalink
PR Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosdelest committed Apr 5, 2024
1 parent d78acc3 commit 7a2b70b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public Iterator<Setting<?>> 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-";

Expand Down Expand Up @@ -1569,7 +1569,7 @@ private static class IndexMetadataDiff implements Diff<IndexMetadata> {
}
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(),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1709,7 +1709,7 @@ public static IndexMetadata readFrom(StreamInput in, @Nullable Function<String,
builder.putMapping(new MappingMetadata(in));
}
}
if (in.getTransportVersion().onOrAfter(TransportVersions.SEMANTIC_TEXT_FIELD_ADDED)) {
if (in.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_FIELDS_METADATA)) {
var fields = in.readCollectionAsImmutableList(InferenceFieldMetadata::new);
fields.stream().forEach(f -> builder.putInferenceField(f));
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -2521,7 +2521,7 @@ public static IndexMetadata fromXContent(XContentParser parser, Map<String, Mapp
case KEY_STATS:
builder.stats(IndexMetadataStats.fromXContent(parser));
break;
case KEY_FIELD_INFERENCE:
case KEY_INFERENCE_FIELDS:
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
builder.putInferenceField(InferenceFieldMetadata.fromXContent(parser));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* Field mapper that requires to transform its input before indexation through the {@link InferenceService}.
*/
public interface InferenceFieldMapper {
String NAME = "_inference";

/**
* Retrieve the inference metadata associated with this mapper.
Expand Down

0 comments on commit 7a2b70b

Please sign in to comment.