Skip to content

Commit 1cab345

Browse files
committed
move feature into mappers; fix yaml tests
1 parent 05ff647 commit 1cab345

File tree

5 files changed

+53
-29
lines changed

5 files changed

+53
-29
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING;
1818
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.RESCORE_ZERO_VECTOR_QUANTIZED_VECTOR_MAPPING;
1919
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.USE_DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ;
20+
import static org.elasticsearch.index.mapper.vectors.SparseVectorFieldMapper.SPARSE_VECTOR_INDEX_OPTIONS_FEATURE;
2021

2122
/**
2223
* Spec for mapper-related features.
@@ -74,7 +75,8 @@ public Set<NodeFeature> getTestFeatures() {
7475
USE_DEFAULT_OVERSAMPLE_VALUE_FOR_BBQ,
7576
IVF_FORMAT_CLUSTER_FEATURE,
7677
IVF_NESTED_SUPPORT,
77-
SEARCH_LOAD_PER_SHARD
78+
SEARCH_LOAD_PER_SHARD,
79+
SPARSE_VECTOR_INDEX_OPTIONS_FEATURE
7880
);
7981
}
8082
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackFeatures.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
import java.util.Set;
1414

15-
import static org.elasticsearch.index.mapper.vectors.SparseVectorFieldMapper.SPARSE_VECTOR_INDEX_OPTIONS_FEATURE;
16-
1715
/**
1816
* Provides the XPack features that this version of the code supports
1917
*/
@@ -22,9 +20,4 @@ public class XPackFeatures implements FeatureSpecification {
2220
public Set<NodeFeature> getFeatures() {
2321
return Set.of();
2422
}
25-
26-
@Override
27-
public Set<NodeFeature> getTestFeatures() {
28-
return Set.of(SPARSE_VECTOR_INDEX_OPTIONS_FEATURE);
29-
}
3023
}

x-pack/plugin/ml/qa/multi-cluster-tests-with-security/src/test/resources/rest-api-spec/test/multi_cluster/50_sparse_vector.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,31 +252,41 @@ teardown:
252252

253253
- do:
254254
headers:
255-
Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" #test_user credentials
256255
Content-Type: application/json
257256
indices.create:
258257
index: sparse_vector_pruning_test
259258
body:
260259
mappings:
261260
properties:
262-
text:
263-
type: text
264261
ml.tokens:
265262
type: sparse_vector
266263

267264
- match: { acknowledged: true }
268265

269266
- do:
270267
headers:
271-
Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" #test_user credentials
272268
Content-Type: application/json
273-
indices.get_mapping:
269+
indices.get_field_mapping:
274270
index: sparse_vector_pruning_test
271+
fields: ml.tokens
272+
include_defaults: true
275273

276274
# the index_options with pruning defaults will be serialized here explicitly
277-
- match: { sparse_vector_pruning_test.mappings.properties.ml.properties.tokens.index_options.prune: true }
278-
- match: { sparse_vector_pruning_test.mappings.properties.ml.properties.tokens.index_options.pruning_config.tokens_freq_ratio_threshold: 5.0 }
279-
- match: { sparse_vector_pruning_test.mappings.properties.ml.properties.tokens.index_options.pruning_config.tokens_weight_threshold: 0.4 }
275+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.prune: true }
276+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.pruning_config.tokens_freq_ratio_threshold: 5.0 }
277+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.pruning_config.tokens_weight_threshold: 0.4 }
278+
279+
- do:
280+
headers:
281+
Content-Type: application/json
282+
indices.get_field_mapping:
283+
index: sparse_vector_pruning_test
284+
fields: ml.tokens
285+
286+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.prune
287+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_freq_ratio_threshold
288+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_weight_threshold
289+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options
280290

281291
---
282292
"Check sparse_vector token pruning index_options prune missing do not allow config":

x-pack/plugin/ml/qa/multi-cluster-tests-with-security/src/test/resources/rest-api-spec/test/remote_cluster/50_sparse_vector.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,31 +250,41 @@ teardown:
250250

251251
- do:
252252
headers:
253-
Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" #test_user credentials
254253
Content-Type: application/json
255254
indices.create:
256255
index: sparse_vector_pruning_test
257256
body:
258257
mappings:
259258
properties:
260-
text:
261-
type: text
262259
ml.tokens:
263260
type: sparse_vector
264261

265262
- match: { acknowledged: true }
266263

267264
- do:
268265
headers:
269-
Authorization: "Basic dGVzdF91c2VyOngtcGFjay10ZXN0LXBhc3N3b3Jk" #test_user credentials
270266
Content-Type: application/json
271-
indices.get_mapping:
267+
indices.get_field_mapping:
272268
index: sparse_vector_pruning_test
269+
fields: ml.tokens
270+
include_defaults: true
273271

274272
# the index_options with pruning defaults will be serialized here explicitly
275-
- match: { sparse_vector_pruning_test.mappings.properties.ml.properties.tokens.index_options.prune: true }
276-
- match: { sparse_vector_pruning_test.mappings.properties.ml.properties.tokens.index_options.pruning_config.tokens_freq_ratio_threshold: 5.0 }
277-
- match: { sparse_vector_pruning_test.mappings.properties.ml.properties.tokens.index_options.pruning_config.tokens_weight_threshold: 0.4 }
273+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.prune: true }
274+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.pruning_config.tokens_freq_ratio_threshold: 5.0 }
275+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.pruning_config.tokens_weight_threshold: 0.4 }
276+
277+
- do:
278+
headers:
279+
Content-Type: application/json
280+
indices.get_field_mapping:
281+
index: sparse_vector_pruning_test
282+
fields: ml.tokens
283+
284+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.prune
285+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_freq_ratio_threshold
286+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_weight_threshold
287+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options
278288

279289
---
280290
"Check sparse_vector token pruning index_options prune missing do not allow config":

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/ml/sparse_vector_search.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,6 @@ teardown:
585585
body:
586586
mappings:
587587
properties:
588-
text:
589-
type: text
590588
ml.tokens:
591589
type: sparse_vector
592590

@@ -601,10 +599,21 @@ teardown:
601599
include_defaults: true
602600

603601
# the index_options with pruning defaults will be serialized here explicitly
604-
- match: { sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.prune: true }
605-
- match: { sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_freq_ratio_threshold: 5.0 }
606-
- match: { sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_weight_threshold: 0.4 }
602+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.prune: true }
603+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.pruning_config.tokens_freq_ratio_threshold: 5.0 }
604+
- match: { sparse_vector_pruning_test.mappings.ml\.tokens.mapping.tokens.index_options.pruning_config.tokens_weight_threshold: 0.4 }
605+
606+
- do:
607+
headers:
608+
Content-Type: application/json
609+
indices.get_field_mapping:
610+
index: sparse_vector_pruning_test
611+
fields: ml.tokens
607612

613+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.prune
614+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_freq_ratio_threshold
615+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options.pruning_config.tokens_weight_threshold
616+
- not_exists: sparse_vector_pruning_test.mappings.ml.tokens.mapping.tokens.index_options
608617

609618
---
610619
"Check sparse_vector token pruning index_options prune missing do not allow config":

0 commit comments

Comments
 (0)