Skip to content

Commit 2015a2d

Browse files
committed
PR feedback
1 parent 98108c0 commit 2015a2d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ public SemanticTextFieldMapper build(MapperBuilderContext context) {
398398
validateServiceSettings(modelSettings.get(), resolvedModelSettings);
399399
}
400400

401+
// If index_options are specified by the user, we will validate them against the model settings to ensure compatibility.
402+
// We do not serialize or otherwise store model settings at this time, this happens when the underlying vector field is created.
401403
SemanticTextIndexOptions builderIndexOptions = indexOptions.get();
402404
if (context.getMergeReason() != MapperService.MergeReason.MAPPING_RECOVERY && builderIndexOptions != null) {
403405
validateIndexOptions(builderIndexOptions, inferenceId.getValue(), resolvedModelSettings);
@@ -1200,6 +1202,9 @@ private static Mapper.Builder createEmbeddingsField(
12001202
}
12011203
denseVectorMapperBuilder.dimensions(modelSettings.dimensions());
12021204
denseVectorMapperBuilder.elementType(modelSettings.elementType());
1205+
// Here is where we persist index_options. If they are specified by the user, we will use those index_options,
1206+
// otherwise we will determine if we can set default index options. If we can't, we won't persist any index_options
1207+
// and the field will use the defaults for the dense_vector field.
12031208
if (indexOptions != null) {
12041209
DenseVectorFieldMapper.DenseVectorIndexOptions denseVectorIndexOptions =
12051210
(DenseVectorFieldMapper.DenseVectorIndexOptions) indexOptions.indexOptions();

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextIndexOptions.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,17 @@ public IndexOptions indexOptions() {
5252
}
5353

5454
@Override
55-
public boolean equals(Object o) {
56-
if (o instanceof SemanticTextIndexOptions == false) return false;
57-
SemanticTextIndexOptions that = (SemanticTextIndexOptions) o;
58-
return type == that.type && Objects.equals(indexOptions, that.indexOptions);
55+
public boolean equals(Object other) {
56+
if (other == this) {
57+
return true;
58+
}
59+
60+
if (other == null || getClass() != other.getClass()) {
61+
return false;
62+
}
63+
64+
SemanticTextIndexOptions otherSemanticTextIndexOptions = (SemanticTextIndexOptions) other;
65+
return type == otherSemanticTextIndexOptions.type && Objects.equals(indexOptions, otherSemanticTextIndexOptions.indexOptions);
5966
}
6067

6168
@Override

0 commit comments

Comments
 (0)