forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add yml tests and improve error message for invalid format
- Loading branch information
Showing
4 changed files
with
267 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
242 changes: 242 additions & 0 deletions
242
.../src/yamlRestTest/resources/rest-api-spec/test/inference/90_semantic_text_highlighter.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
setup: | ||
- requires: | ||
cluster_features: "semantic_text.highlighter" | ||
reason: a new highlighter for semantic text field | ||
|
||
- do: | ||
inference.put: | ||
task_type: sparse_embedding | ||
inference_id: sparse-inference-id | ||
body: > | ||
{ | ||
"service": "test_service", | ||
"service_settings": { | ||
"model": "my_model", | ||
"api_key": "abc64" | ||
}, | ||
"task_settings": { | ||
} | ||
} | ||
- do: | ||
inference.put: | ||
task_type: text_embedding | ||
inference_id: dense-inference-id | ||
body: > | ||
{ | ||
"service": "text_embedding_test_service", | ||
"service_settings": { | ||
"model": "my_model", | ||
"dimensions": 10, | ||
"api_key": "abc64", | ||
"similarity": "COSINE" | ||
}, | ||
"task_settings": { | ||
} | ||
} | ||
- do: | ||
indices.create: | ||
index: test-sparse-index | ||
body: | ||
mappings: | ||
properties: | ||
body: | ||
type: semantic_text | ||
inference_id: sparse-inference-id | ||
|
||
- do: | ||
indices.create: | ||
index: test-dense-index | ||
body: | ||
mappings: | ||
properties: | ||
body: | ||
type: semantic_text | ||
inference_id: dense-inference-id | ||
|
||
--- | ||
"Highlighting using a sparse embedding model": | ||
- do: | ||
index: | ||
index: test-sparse-index | ||
id: doc_1 | ||
body: | ||
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!"] | ||
refresh: true | ||
|
||
- match: { result: created } | ||
|
||
- do: | ||
search: | ||
index: test-sparse-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
number_of_fragments: 1 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 1 } | ||
- 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." } | ||
|
||
- do: | ||
search: | ||
index: test-sparse-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
number_of_fragments: 2 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 2 } | ||
- 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." } | ||
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" } | ||
|
||
- do: | ||
search: | ||
index: test-sparse-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
order: "score" | ||
number_of_fragments: 1 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 1 } | ||
- 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." } | ||
|
||
- do: | ||
search: | ||
index: test-sparse-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
order: "score" | ||
number_of_fragments: 2 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 2 } | ||
- 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." } | ||
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" } | ||
|
||
--- | ||
"Highlighting using a dense embedding model": | ||
- do: | ||
index: | ||
index: test-dense-index | ||
id: doc_1 | ||
body: | ||
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!"] | ||
refresh: true | ||
|
||
- match: { result: created } | ||
|
||
- do: | ||
search: | ||
index: test-dense-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
number_of_fragments: 1 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 1 } | ||
- match: { hits.hits.0.highlight.body.0: "You Know, for Search!" } | ||
|
||
- do: | ||
search: | ||
index: test-dense-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
number_of_fragments: 2 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 2 } | ||
- 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." } | ||
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" } | ||
|
||
- do: | ||
search: | ||
index: test-dense-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
order: "score" | ||
number_of_fragments: 1 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 1 } | ||
- match: { hits.hits.0.highlight.body.0: "You Know, for Search!" } | ||
|
||
- do: | ||
search: | ||
index: test-dense-index | ||
body: | ||
query: | ||
semantic: | ||
field: "body" | ||
query: "What is Elasticsearch?" | ||
highlight: | ||
fields: | ||
body: | ||
type: "semantic" | ||
order: "score" | ||
number_of_fragments: 2 | ||
|
||
- match: { hits.total.value: 1 } | ||
- match: { hits.hits.0._id: "doc_1" } | ||
- length: { hits.hits.0.highlight.body: 2 } | ||
- match: { hits.hits.0.highlight.body.0: "You Know, for Search!" } | ||
- match: { hits.hits.0.highlight.body.1: "ElasticSearch is an open source, distributed, RESTful, search engine which is built on top of Lucene internally and enjoys all the features it provides." } | ||
|
||
|