Skip to content

Commit f75d236

Browse files
Adding more restrictive checks on yaml tests and few refactoring
1 parent f2e5dae commit f75d236

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,10 @@ public KeywordFieldMapper build(MapperBuilderContext context) {
455455
indexCreatedVersion,
456456
IndexVersions.SYNTHETIC_SOURCE_STORE_ARRAYS_NATIVELY_KEYWORD
457457
);
458-
459-
KeywordFieldType keywordFieldType = buildFieldType(context, fieldtype);
460458
return new KeywordFieldMapper(
461459
leafName(),
462460
fieldtype,
463-
keywordFieldType,
461+
buildFieldType(context, fieldtype),
464462
builderParams(this, context),
465463
context.isSourceSynthetic(),
466464
useDocValuesSkipper,

server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public final boolean isStored() {
185185
}
186186

187187
/**
188-
* @return true if fieldType is subfields of semantic_text type
188+
* @return true if the field should be excluded from field caps
189189
*/
190190
public boolean excludeFromFieldCaps() {
191191
return excludeFromFieldCaps;

server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public Builder setStored(boolean value) {
8484
return this;
8585
}
8686

87-
public Builder setExcludeFromFieldCaps(boolean value) {
87+
public Builder excludeFromFieldCaps(boolean value) {
8888
excludeFromFieldCaps = value;
8989
return this;
9090
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import java.util.Set;
1717

18-
import static org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper.SEMANTIC_TEXT_SUB_FIELDS_EXCLUDE_FROM_FIELD_CAPS;
18+
import static org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper.SEMANTIC_TEXT_EXCLUDE_SUB_FIELDS_FROM_FIELD_CAPS;
1919
import static org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper.SEMANTIC_TEXT_SUPPORT_CHUNKING_CONFIG;
2020
import static org.elasticsearch.xpack.inference.queries.SemanticKnnVectorQueryRewriteInterceptor.SEMANTIC_KNN_FILTER_FIX;
2121
import static org.elasticsearch.xpack.inference.queries.SemanticKnnVectorQueryRewriteInterceptor.SEMANTIC_KNN_VECTOR_QUERY_REWRITE_INTERCEPTION_SUPPORTED;
@@ -59,7 +59,7 @@ public Set<NodeFeature> getTestFeatures() {
5959
SemanticTextFieldMapper.SEMANTIC_TEXT_HANDLE_EMPTY_INPUT,
6060
TEST_RULE_RETRIEVER_WITH_INDICES_THAT_DONT_RETURN_RANK_DOCS,
6161
SEMANTIC_TEXT_SUPPORT_CHUNKING_CONFIG,
62-
SEMANTIC_TEXT_SUB_FIELDS_EXCLUDE_FROM_FIELD_CAPS
62+
SEMANTIC_TEXT_EXCLUDE_SUB_FIELDS_FROM_FIELD_CAPS
6363
);
6464
}
6565
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public class SemanticTextFieldMapper extends FieldMapper implements InferenceFie
134134
public static final NodeFeature SEMANTIC_TEXT_SKIP_INFERENCE_FIELDS = new NodeFeature("semantic_text.skip_inference_fields");
135135
public static final NodeFeature SEMANTIC_TEXT_BIT_VECTOR_SUPPORT = new NodeFeature("semantic_text.bit_vector_support");
136136
public static final NodeFeature SEMANTIC_TEXT_SUPPORT_CHUNKING_CONFIG = new NodeFeature("semantic_text.support_chunking_config");
137-
public static final NodeFeature SEMANTIC_TEXT_SUB_FIELDS_EXCLUDE_FROM_FIELD_CAPS = new NodeFeature(
137+
public static final NodeFeature SEMANTIC_TEXT_EXCLUDE_SUB_FIELDS_FROM_FIELD_CAPS = new NodeFeature(
138138
"semantic_text.exclude_sub_fields_from_field_caps"
139139
);
140140

@@ -1063,7 +1063,7 @@ private static Mapper.Builder createEmbeddingsField(
10631063
) {
10641064
return switch (modelSettings.taskType()) {
10651065
case SPARSE_EMBEDDING -> new SparseVectorFieldMapper.Builder(CHUNKED_EMBEDDINGS_FIELD).setStored(useLegacyFormat == false)
1066-
.setExcludeFromFieldCaps(true);
1066+
.excludeFromFieldCaps(true);
10671067
case TEXT_EMBEDDING -> {
10681068
DenseVectorFieldMapper.Builder denseVectorMapperBuilder = new DenseVectorFieldMapper.Builder(
10691069
CHUNKED_EMBEDDINGS_FIELD,

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ setup:
364364
"Field caps exclude chunks and embedding fields":
365365
- requires:
366366
cluster_features: "semantic_text.exclude_sub_fields_from_field_caps"
367-
reason: field caps api exclude semantic_text subfields from 9.1.0
367+
reason: field caps api exclude semantic_text subfields from 9.1.0 & 8.19.0
368368

369369
- do:
370370
field_caps:
@@ -375,7 +375,11 @@ setup:
375375
- match: { indices: [ "test-index" ] }
376376
- exists: fields.sparse_field
377377
- exists: fields.dense_field
378-
- not_exists: fields.sparse_field.chunks.embeddings
379-
- not_exists: fields.sparse_field.chunks.offset
380-
- not_exists: fields.dense_field.chunks.embeddings
381-
- not_exists: fields.dense_field.chunks.offset
378+
- not_exists: fields.sparse_field.inference.chunks.embeddings
379+
- not_exists: fields.sparse_field.inference.chunks.offset
380+
- not_exists: fields.sparse_field.inference.chunks
381+
- not_exists: fields.sparse_field.inference
382+
- not_exists: fields.dense_field.inference.chunks.embeddings
383+
- not_exists: fields.dense_field.inference.chunks.offset
384+
- not_exists: fields.dense_field.inference.chunks
385+
- not_exists: fields.dense_field.inference

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping_bwc.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ setup:
311311
"Field caps exclude chunks embedding and text fields":
312312
- requires:
313313
cluster_features: "semantic_text.exclude_sub_fields_from_field_caps"
314-
reason: field caps api exclude semantic_text subfields from 9.1.0
314+
reason: field caps api exclude semantic_text subfields from 9.1.0 & 8.19.0
315315

316316
- do:
317317
field_caps:
@@ -324,5 +324,9 @@ setup:
324324
- exists: fields.dense_field
325325
- not_exists: fields.sparse_field.inference.chunks.embeddings
326326
- not_exists: fields.sparse_field.inference.chunks.text
327+
- not_exists: fields.sparse_field.inference.chunks
328+
- not_exists: fields.sparse_field.inference
327329
- not_exists: fields.dense_field.inference.chunks.embeddings
328330
- not_exists: fields.dense_field.inference.chunks.text
331+
- not_exists: fields.dense_field.inference.chunks
332+
- not_exists: fields.dense_field.inference

0 commit comments

Comments
 (0)