Skip to content

Commit 58b9a59

Browse files
authored
chore(SemanticTextHighlighter): improve bwc tests (elastic#138662)
1 parent e8749d9 commit 58b9a59

File tree

2 files changed

+150
-88
lines changed

2 files changed

+150
-88
lines changed

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/90_semantic_text_highlighter.yml

Lines changed: 75 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -745,81 +745,52 @@ setup:
745745
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
746746

747747
---
748-
"Highlighting with type:bbq_disk index options as well as knn with similarity":
748+
"Highlighting with knn with similarity":
749749
- requires:
750-
cluster_features: "semantic_text.highlighter.bbq_and_similarity_support"
751-
reason: semantic highlighter fix for disk_bbq index options and knn with similarity
752-
753-
- do:
754-
indices.create:
755-
index: test-dense-index-bbq_disk
756-
body:
757-
settings:
758-
index.mapping.semantic_text.use_legacy_format: false
759-
mappings:
760-
properties:
761-
bbq_disk_body:
762-
type: semantic_text
763-
inference_id: dense-inference-id
764-
index_options:
765-
dense_vector:
766-
type: bbq_disk
767-
body:
768-
type: semantic_text
769-
inference_id: dense-inference-id
750+
cluster_features: "semantic_text.highlighter.vector_similarity_support"
751+
reason: semantic highlighter fix for knn with similarity
770752

771753
- do:
772754
index:
773-
index: test-dense-index-bbq_disk
755+
index: test-dense-index
774756
id: doc_1
775757
body:
776-
bbq_disk_body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!", "For a moment, nothing happened. Then, after a second or so, nothing continued to happen." ]
777758
body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!", "For a moment, nothing happened. Then, after a second or so, nothing continued to happen." ]
778759
- do:
779760
index:
780-
index: test-dense-index-bbq_disk
761+
index: test-dense-index
781762
id: doc_2
782763
body:
783-
bbq_disk_body: [ "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws."]
784764
body: [ "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws."]
785765
refresh: true
786766

787767
- do:
788768
search:
789-
index: test-dense-index-bbq_disk
769+
index: test-dense-index
790770
body:
791771
query:
792772
match_all: { }
793773
highlight:
794774
fields:
795-
bbq_disk_body:
796-
type: "semantic"
797-
number_of_fragments: 1
798775
body:
799776
type: "semantic"
800777
number_of_fragments: 1
801778

802779
- match: { hits.total.value: 2 }
803780

804781
- match: { hits.hits.0._id: "doc_1" }
805-
- length: { hits.hits.0.highlight: 2 }
806-
- length: { hits.hits.0.highlight.bbq_disk_body: 1 }
807-
- match: { hits.hits.0.highlight.bbq_disk_body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
782+
- length: { hits.hits.0.highlight: 1 }
808783
- length: { hits.hits.0.highlight.body: 1 }
809784
- match: { hits.hits.0.highlight.body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
810785

811786
- match: { hits.hits.1._id: "doc_2" }
812-
- length: { hits.hits.1.highlight: 2 }
813-
- length: { hits.hits.1.highlight.bbq_disk_body: 1 }
814-
- match: { hits.hits.1.highlight.bbq_disk_body.0: "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws." }
787+
- length: { hits.hits.1.highlight: 1 }
815788
- length: { hits.hits.1.highlight.body: 1 }
816789
- match: { hits.hits.1.highlight.body.0: "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws." }
817790

818-
819-
820791
- do:
821792
search:
822-
index: test-dense-index-bbq_disk
793+
index: test-dense-index
823794
body:
824795
query:
825796
knn:
@@ -843,6 +814,65 @@ setup:
843814
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
844815
- match: { hits.hits.0.highlight.body.2: "For a moment, nothing happened. Then, after a second or so, nothing continued to happen."}
845816

817+
---
818+
"Highlighting with type:bbq_disk index options":
819+
- requires:
820+
cluster_features: "semantic_text.highlighter.bbq_and_similarity_support"
821+
reason: semantic highlighter fix for disk_bbq index options and knn with similarity
822+
823+
- do:
824+
indices.create:
825+
index: test-dense-index-bbq_disk
826+
body:
827+
settings:
828+
index.mapping.semantic_text.use_legacy_format: false
829+
mappings:
830+
properties:
831+
bbq_disk_body:
832+
type: semantic_text
833+
inference_id: dense-inference-id-compatible-with-bbq
834+
index_options:
835+
dense_vector:
836+
type: bbq_disk
837+
838+
- do:
839+
index:
840+
index: test-dense-index-bbq_disk
841+
id: doc_1
842+
body:
843+
bbq_disk_body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!", "For a moment, nothing happened. Then, after a second or so, nothing continued to happen." ]
844+
- do:
845+
index:
846+
index: test-dense-index-bbq_disk
847+
id: doc_2
848+
body:
849+
bbq_disk_body: [ "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws."]
850+
refresh: true
851+
852+
- do:
853+
search:
854+
index: test-dense-index-bbq_disk
855+
body:
856+
query:
857+
match_all: { }
858+
highlight:
859+
fields:
860+
bbq_disk_body:
861+
type: "semantic"
862+
number_of_fragments: 1
863+
864+
- match: { hits.total.value: 2 }
865+
866+
- match: { hits.hits.0._id: "doc_1" }
867+
- length: { hits.hits.0.highlight: 1 }
868+
- length: { hits.hits.0.highlight.bbq_disk_body: 1 }
869+
- match: { hits.hits.0.highlight.bbq_disk_body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
870+
871+
- match: { hits.hits.1._id: "doc_2" }
872+
- length: { hits.hits.1.highlight: 1 }
873+
- length: { hits.hits.1.highlight.bbq_disk_body: 1 }
874+
- match: { hits.hits.1.highlight.bbq_disk_body.0: "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws." }
875+
846876
- do:
847877
search:
848878
index: test-dense-index-bbq_disk
@@ -855,18 +885,19 @@ setup:
855885
model_text: "What is Elasticsearch?"
856886
k: 10
857887
num_candidates: 10
858-
similarity: 0.9977
888+
similarity: 0.9975
859889
highlight:
860890
fields:
861-
body:
891+
bbq_disk_body:
862892
type: "semantic"
863-
number_of_fragments: 2
893+
number_of_fragments: 3
864894

865895
- match: { hits.total.value: 1 }
866896
- match: { hits.hits.0._id: "doc_1" }
867-
- length: { hits.hits.0.highlight.body: 2 }
868-
- match: { hits.hits.0.highlight.body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
869-
- match: { hits.hits.0.highlight.body.1: "For a moment, nothing happened. Then, after a second or so, nothing continued to happen."}
897+
- length: { hits.hits.0.highlight.bbq_disk_body: 3 }
898+
- match: { hits.hits.0.highlight.bbq_disk_body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
899+
- match: { hits.hits.0.highlight.bbq_disk_body.1: "You Know, for Search!" }
900+
- match: { hits.hits.0.highlight.bbq_disk_body.2: "For a moment, nothing happened. Then, after a second or so, nothing continued to happen."}
870901

871902
- do:
872903
search:

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/90_semantic_text_highlighter_bwc.yml

Lines changed: 75 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -650,81 +650,52 @@ setup:
650650
- match: { hits.hits.0.highlight.bbq_hnsw_field.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
651651

652652
---
653-
"Highlighting with type:bbq_disk index options as well as knn with similarity":
653+
"Highlighting with knn with similarity":
654654
- requires:
655-
cluster_features: "semantic_text.highlighter.bbq_and_similarity_support"
656-
reason: semantic highlighter fix for disk_bbq index options and knn with similarity
657-
658-
- do:
659-
indices.create:
660-
index: test-dense-index-bbq_disk
661-
body:
662-
settings:
663-
index.mapping.semantic_text.use_legacy_format: true
664-
mappings:
665-
properties:
666-
bbq_disk_body:
667-
type: semantic_text
668-
inference_id: dense-inference-id
669-
index_options:
670-
dense_vector:
671-
type: bbq_disk
672-
body:
673-
type: semantic_text
674-
inference_id: dense-inference-id
655+
cluster_features: "semantic_text.highlighter.vector_similarity_support"
656+
reason: semantic highlighter fix for knn with similarity
675657

676658
- do:
677659
index:
678-
index: test-dense-index-bbq_disk
660+
index: test-dense-index
679661
id: doc_1
680662
body:
681-
bbq_disk_body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!", "For a moment, nothing happened. Then, after a second or so, nothing continued to happen." ]
682663
body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!", "For a moment, nothing happened. Then, after a second or so, nothing continued to happen." ]
683664
- do:
684665
index:
685-
index: test-dense-index-bbq_disk
666+
index: test-dense-index
686667
id: doc_2
687668
body:
688-
bbq_disk_body: [ "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws."]
689669
body: [ "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws."]
690670
refresh: true
691671

692672
- do:
693673
search:
694-
index: test-dense-index-bbq_disk
674+
index: test-dense-index
695675
body:
696676
query:
697677
match_all: { }
698678
highlight:
699679
fields:
700-
bbq_disk_body:
701-
type: "semantic"
702-
number_of_fragments: 1
703680
body:
704681
type: "semantic"
705682
number_of_fragments: 1
706683

707684
- match: { hits.total.value: 2 }
708685

709686
- match: { hits.hits.0._id: "doc_1" }
710-
- length: { hits.hits.0.highlight: 2 }
711-
- length: { hits.hits.0.highlight.bbq_disk_body: 1 }
712-
- match: { hits.hits.0.highlight.bbq_disk_body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
687+
- length: { hits.hits.0.highlight: 1 }
713688
- length: { hits.hits.0.highlight.body: 1 }
714689
- match: { hits.hits.0.highlight.body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
715690

716691
- match: { hits.hits.1._id: "doc_2" }
717-
- length: { hits.hits.1.highlight: 2 }
718-
- length: { hits.hits.1.highlight.bbq_disk_body: 1 }
719-
- match: { hits.hits.1.highlight.bbq_disk_body.0: "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws." }
692+
- length: { hits.hits.1.highlight: 1 }
720693
- length: { hits.hits.1.highlight.body: 1 }
721694
- match: { hits.hits.1.highlight.body.0: "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws." }
722695

723-
724-
725696
- do:
726697
search:
727-
index: test-dense-index-bbq_disk
698+
index: test-dense-index
728699
body:
729700
query:
730701
knn:
@@ -748,6 +719,65 @@ setup:
748719
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
749720
- match: { hits.hits.0.highlight.body.2: "For a moment, nothing happened. Then, after a second or so, nothing continued to happen."}
750721

722+
---
723+
"Highlighting with type:bbq_disk index options":
724+
- requires:
725+
cluster_features: "semantic_text.highlighter.bbq_and_similarity_support"
726+
reason: semantic highlighter fix for disk_bbq index options and knn with similarity
727+
728+
- do:
729+
indices.create:
730+
index: test-dense-index-bbq_disk
731+
body:
732+
settings:
733+
index.mapping.semantic_text.use_legacy_format: true
734+
mappings:
735+
properties:
736+
bbq_disk_body:
737+
type: semantic_text
738+
inference_id: dense-inference-id-compatible-with-bbq
739+
index_options:
740+
dense_vector:
741+
type: bbq_disk
742+
743+
- do:
744+
index:
745+
index: test-dense-index-bbq_disk
746+
id: doc_1
747+
body:
748+
bbq_disk_body: [ "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides.", "You Know, for Search!", "For a moment, nothing happened. Then, after a second or so, nothing continued to happen." ]
749+
- do:
750+
index:
751+
index: test-dense-index-bbq_disk
752+
id: doc_2
753+
body:
754+
bbq_disk_body: [ "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws."]
755+
refresh: true
756+
757+
- do:
758+
search:
759+
index: test-dense-index-bbq_disk
760+
body:
761+
query:
762+
match_all: { }
763+
highlight:
764+
fields:
765+
bbq_disk_body:
766+
type: "semantic"
767+
number_of_fragments: 1
768+
769+
- match: { hits.total.value: 2 }
770+
771+
- match: { hits.hits.0._id: "doc_1" }
772+
- length: { hits.hits.0.highlight: 1 }
773+
- length: { hits.hits.0.highlight.bbq_disk_body: 1 }
774+
- match: { hits.hits.0.highlight.bbq_disk_body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
775+
776+
- match: { hits.hits.1._id: "doc_2" }
777+
- length: { hits.hits.1.highlight: 1 }
778+
- length: { hits.hits.1.highlight.bbq_disk_body: 1 }
779+
- match: { hits.hits.1.highlight.bbq_disk_body.0: "Nothing travels faster than the speed of light with the possible exception of bad news, which obeys its own special laws." }
780+
751781
- do:
752782
search:
753783
index: test-dense-index-bbq_disk
@@ -760,18 +790,19 @@ setup:
760790
model_text: "What is Elasticsearch?"
761791
k: 10
762792
num_candidates: 10
763-
similarity: 0.9977
793+
similarity: 0.9975
764794
highlight:
765795
fields:
766-
body:
796+
bbq_disk_body:
767797
type: "semantic"
768-
number_of_fragments: 2
798+
number_of_fragments: 3
769799

770800
- match: { hits.total.value: 1 }
771801
- match: { hits.hits.0._id: "doc_1" }
772-
- length: { hits.hits.0.highlight.body: 2 }
773-
- match: { hits.hits.0.highlight.body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
774-
- match: { hits.hits.0.highlight.body.1: "For a moment, nothing happened. Then, after a second or so, nothing continued to happen."}
802+
- length: { hits.hits.0.highlight.bbq_disk_body: 3 }
803+
- match: { hits.hits.0.highlight.bbq_disk_body.0: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." }
804+
- match: { hits.hits.0.highlight.bbq_disk_body.1: "You Know, for Search!" }
805+
- match: { hits.hits.0.highlight.bbq_disk_body.2: "For a moment, nothing happened. Then, after a second or so, nothing continued to happen."}
775806

776807
- do:
777808
search:

0 commit comments

Comments
 (0)