Skip to content

Commit 4f933fc

Browse files
committed
Fix some yaml tests
1 parent d65c011 commit 4f933fc

File tree

2 files changed

+287
-170
lines changed

2 files changed

+287
-170
lines changed

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

Lines changed: 91 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,39 @@ setup:
33
cluster_features: "gte_v8.15.0"
44
reason: semantic_text introduced in 8.15.0
55

6+
- do:
7+
inference.put:
8+
task_type: sparse_embedding
9+
inference_id: sparse-inference-id
10+
body: >
11+
{
12+
"service": "test_service",
13+
"service_settings": {
14+
"model": "my_model",
15+
"api_key": "abc64"
16+
},
17+
"task_settings": {
18+
}
19+
}
20+
21+
- do:
22+
inference.put:
23+
task_type: text_embedding
24+
inference_id: dense-inference-id
25+
body: >
26+
{
27+
"service": "text_embedding_test_service",
28+
"service_settings": {
29+
"model": "my_model",
30+
"dimensions": 10,
31+
"similarity": "cosine",
32+
"api_key": "abc64"
33+
},
34+
"task_settings": {
35+
}
36+
}
37+
38+
639
- do:
740
indices.create:
841
index: test-index
@@ -381,19 +414,20 @@ setup:
381414
type: semantic_text
382415
inference_id: dense-inference-id
383416
index_options:
384-
type: int8_hnsw
385-
m: 16
386-
ef_construction: 100
387-
confidence_interval: 1.0
417+
dense_vector:
418+
type: int8_hnsw
419+
m: 16
420+
ef_construction: 100
421+
confidence_interval: 1.0
388422

389423
- do:
390424
indices.get_mapping:
391425
index: test-index-options
392426

393-
- match: { "test-index-options.mappings.properties.semantic_field.index_options.type": "int8_hnsw" }
394-
- match: { "test-index-options.mappings.properties.semantic_field.index_options.m": 16 }
395-
- match: { "test-index-options.mappings.properties.semantic_field.index_options.ef_construction": 100 }
396-
- match: { "test-index-options.mappings.properties.semantic_field.index_options.confidence_interval": 1.0 }
427+
- match: { "test-index-options.mappings.properties.semantic_field.index_options.dense_vector.type": "int8_hnsw" }
428+
- match: { "test-index-options.mappings.properties.semantic_field.index_options.dense_vector.m": 16 }
429+
- match: { "test-index-options.mappings.properties.semantic_field.index_options.dense_vector.ef_construction": 100 }
430+
- match: { "test-index-options.mappings.properties.semantic_field.index_options.dense_vector.confidence_interval": 1.0 }
397431

398432
- do:
399433
index:
@@ -409,6 +443,12 @@ setup:
409443
dimensions: 4
410444
similarity: cosine
411445
element_type: float
446+
index_options:
447+
dense_vector:
448+
type: int8_hnsw
449+
m: 16
450+
ef_construction: 100
451+
confidence_interval: 1.0
412452
chunks:
413453
semantic_field:
414454
- start_offset: 0
@@ -446,15 +486,16 @@ setup:
446486
type: semantic_text
447487
inference_id: dense-inference-id
448488
index_options:
449-
type: int8_hnsw
489+
dense_vector:
490+
type: int8_hnsw
450491

451492
- do:
452493
indices.get_mapping:
453494
index: test-index-options
454495

455-
- match: { "test-index-options.mappings.properties.semantic_field.index_options.type": "int8_hnsw" }
456-
- match: { "test-index-options.mappings.properties.semantic_field.index_options.m": 16 }
457-
- match: { "test-index-options.mappings.properties.semantic_field.index_options.ef_construction": 100 }
496+
- match: { "test-index-options.mappings.properties.semantic_field.dense_vector.index_options.type": "int8_hnsw" }
497+
- match: { "test-index-options.mappings.properties.semantic_field.index_options.dense_vector.m": 16 }
498+
- match: { "test-index-options.mappings.properties.semantic_field.index_options.dense_vector.ef_construction": 100 }
458499

459500
- do:
460501
index:
@@ -486,66 +527,6 @@ setup:
486527

487528
- match: { _source.semantic_field: "these are not the droids you're looking for. He's free to go around" }
488529

489-
#---
490-
#"Index options automatically infer a task type of text_embedding, so requests using sparse_embedding models will fail":
491-
# - requires:
492-
# cluster_features: "semantic_text.index_options"
493-
# reason: Index options introduced in 8.18.0
494-
#
495-
# - do:
496-
# indices.create:
497-
# index: test-index-options
498-
# body:
499-
# settings:
500-
# index:
501-
# mapping:
502-
# semantic_text:
503-
# use_legacy_format: false
504-
# mappings:
505-
# properties:
506-
# semantic_field:
507-
# type: semantic_text
508-
# inference_id: sparse-inference-id
509-
# index_options:
510-
# type: int8_hnsw
511-
#
512-
# - do:
513-
# indices.get_mapping:
514-
# index: test-index-options
515-
#
516-
# - match: { "test-index-options.mappings.properties.semantic_field.index_options.type": "int8_hnsw" }
517-
# - match: { "test-index-options.mappings.properties.semantic_field.index_options.m": 16 }
518-
# - match: { "test-index-options.mappings.properties.semantic_field.index_options.ef_construction": 100 }
519-
#
520-
# - do:
521-
# catch: /Cannot update parameter \[model_settings\] from \[task_type=text_embedding\] to \[task_type=sparse_embedding\]/
522-
# index:
523-
# index: test-index-options
524-
# id: doc_1
525-
# body:
526-
# semantic_field: "these are not the droids you're looking for. He's free to go around"
527-
# _inference_fields.semantic_field:
528-
# inference:
529-
# inference_id: sparse-inference-id
530-
# model_settings:
531-
# task_type: sparse_embedding
532-
# chunks:
533-
# semantic_field:
534-
# - start_offset: 0
535-
# end_offset: 44
536-
# embeddings:
537-
# feature_0: 1.0
538-
# feature_1: 2.0
539-
# feature_2: 3.0
540-
# feature_3: 4.0
541-
# - start_offset: 44
542-
# end_offset: 67
543-
# embeddings:
544-
# feature_4: 0.1
545-
# feature_5: 0.2
546-
# feature_6: 0.3
547-
# feature_7: 0.4
548-
549530

550531
---
551532
"Not specifying index options does not return index options":
@@ -597,8 +578,9 @@ setup:
597578
type: semantic_text
598579
inference_id: dense-inference-id
599580
index_options:
600-
type: bbq_flat
601-
ef_construction: 100
581+
dense_vector:
582+
type: bbq_flat
583+
ef_construction: 100
602584

603585
---
604586
"Specifying unsupported index option types will fail":
@@ -607,7 +589,7 @@ setup:
607589
reason: Index options introduced in 8.18.0
608590

609591
- do:
610-
catch: /Unsupported index options type \[foo\]/
592+
catch: /Unsupported index options type/
611593
indices.create:
612594
index: test-invalid-index-options-dense
613595
body:
@@ -622,10 +604,10 @@ setup:
622604
type: semantic_text
623605
inference_id: dense-inference-id
624606
index_options:
625-
type: foo
626-
607+
dense_vector:
608+
type: foo
627609
- do:
628-
catch: /Unsupported index options type \[foo\]/
610+
catch: bad_request
629611
indices.create:
630612
index: test-invalid-index-options-sparse
631613
body:
@@ -639,7 +621,8 @@ setup:
639621
semantic_field:
640622
type: semantic_text
641623
index_options:
642-
type: foo
624+
sparse_vector:
625+
type: int8_hnsw
643626

644627
---
645628
"Index option type is required":
@@ -648,7 +631,7 @@ setup:
648631
reason: Index options introduced in 8.18.0
649632

650633
- do:
651-
catch: /Required \[type\]/
634+
catch: /Required type/
652635
indices.create:
653636
index: test-invalid-index-options-dense
654637
body:
@@ -663,12 +646,19 @@ setup:
663646
type: semantic_text
664647
inference_id: dense-inference-id
665648
index_options:
666-
foo: bar
649+
dense_vector:
650+
foo: bar
651+
652+
---
653+
"Model is required for index options":
654+
- requires:
655+
cluster_features: "semantic_text.index_options"
656+
reason: Index options introduced in 8.18.0
667657

668658
- do:
669-
catch: /Required \[type\]/
659+
catch: /Model settings must be set to validate index options/
670660
indices.create:
671-
index: test-invalid-index-options-sparse
661+
index: test-no-model
672662
body:
673663
settings:
674664
index:
@@ -679,6 +669,22 @@ setup:
679669
properties:
680670
semantic_field:
681671
type: semantic_text
682-
inference_id: sparse-inference-id
672+
inference_id: nonexistent-inference-id
683673
index_options:
684-
foo: bar
674+
dense_vector:
675+
type: int8_hnsw
676+
677+
678+
- do:
679+
indices.create:
680+
index: test-no-model
681+
body:
682+
settings:
683+
index:
684+
mapping:
685+
semantic_text:
686+
use_legacy_format: false
687+
mappings:
688+
properties:
689+
semantic_field:
690+
type: semantic_text

0 commit comments

Comments
 (0)