diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml index 146f0e5c62bc9..b119a1a1d94f3 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/nodes.stats/11_indices_metrics.yml @@ -413,7 +413,7 @@ - match: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 0 } --- -"indices mappings count test for indices level": +"indices mappings exact count test for indices level": - skip: features: [arbitrary_key] @@ -468,7 +468,7 @@ - do: nodes.stats: { metric: _all, level: "indices", human: true } - # In the below assertions, we expect a field count of at least 26 because the above mapping expects the following: + # In the below assertions, we expect a field count of 26 because the above mapping expects the following: # Field mappers (incl. alias fields and object mappers' flattened leaves): # 1. _data_stream_timestamp # 2. _doc_count @@ -498,17 +498,13 @@ # 25. authors.name # Runtime field mappers: # 26. a_source_field - # - # Plugins (which may or may not be loaded depending on the context in which this test is executed) may add additional - # field mappers: - # 27. _semantic_text_inference (from ML plugin) - gte: { nodes.$node_id.indices.mappings.total_count: 26 } - is_true: nodes.$node_id.indices.mappings.total_estimated_overhead - gte: { nodes.$node_id.indices.mappings.total_estimated_overhead_in_bytes: 26624 } - - gte: { nodes.$node_id.indices.indices.index1.mappings.total_count: 26 } + - match: { nodes.$node_id.indices.indices.index1.mappings.total_count: 26 } - is_true: nodes.$node_id.indices.indices.index1.mappings.total_estimated_overhead - - gte: { nodes.$node_id.indices.indices.index1.mappings.total_estimated_overhead_in_bytes: 26624 } + - match: { nodes.$node_id.indices.indices.index1.mappings.total_estimated_overhead_in_bytes: 26624 } --- "indices mappings does not exist in shards level": 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 3a852f20a761e..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-"; @@ -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, ToXContentFragment { private static final String INFERENCE_ID_FIELD = "inference_id"; private static final String SOURCE_FIELDS_FIELD = "source_fields"; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java index 3bb82bea58acf..3f83a8819b4c1 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java @@ -1132,10 +1132,6 @@ public String typeName() { return CONTENT_TYPE; } - public Integer getDims() { - return dims; - } - @Override public ValueFetcher valueFetcher(SearchExecutionContext context, String format) { if (format != null) { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java index 58286d34dada1..6532abed19044 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java @@ -171,12 +171,9 @@ public void parse(DocumentParserContext context) throws IOException { } String feature = null; - boolean origIsWithLeafObject = context.path().isWithinLeafObject(); try { // make sure that we don't expand dots in field names while parsing - if (context.path().isWithinLeafObject() == false) { - context.path().setWithinLeafObject(true); - } + context.path().setWithinLeafObject(true); for (Token token = context.parser().nextToken(); token != Token.END_OBJECT; token = context.parser().nextToken()) { if (token == Token.FIELD_NAME) { feature = context.parser().currentName(); @@ -210,7 +207,7 @@ public void parse(DocumentParserContext context) throws IOException { context.addToFieldNames(fieldType().name()); } } finally { - context.path().setWithinLeafObject(origIsWithLeafObject); + context.path().setWithinLeafObject(false); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/InferenceFieldMetadataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/InferenceFieldMetadataTests.java index 958d86535ae76..bd4c87be51157 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/InferenceFieldMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/InferenceFieldMetadataTests.java @@ -63,4 +63,10 @@ private static InferenceFieldMetadata createTestItem() { String[] inputFields = generateRandomStringArray(5, 10, false, false); return new InferenceFieldMetadata(name, inferenceId, inputFields); } + + public void testNullCtorArgsThrowException() { + assertThrows(NullPointerException.class, () -> new InferenceFieldMetadata(null, "inferenceId", new String[0])); + assertThrows(NullPointerException.class, () -> new InferenceFieldMetadata("name", null, new String[0])); + assertThrows(NullPointerException.class, () -> new InferenceFieldMetadata("name", "inferenceId", null)); + } }