Skip to content

Commit 9248b7f

Browse files
Adding yaml tests for match_all
1 parent e788bfb commit 9248b7f

File tree

3 files changed

+264
-1
lines changed

3 files changed

+264
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class InferenceFeatures implements FeatureSpecification {
3434
private static final NodeFeature TEST_RULE_RETRIEVER_WITH_INDICES_THAT_DONT_RETURN_RANK_DOCS = new NodeFeature(
3535
"test_rule_retriever.with_indices_that_dont_return_rank_docs"
3636
);
37+
private static final NodeFeature SEMANTIC_TEXT_MATCH_ALL_HIGHLIGHTER = new NodeFeature("semantic_text.match_all_highlighter");
3738

3839
@Override
3940
public Set<NodeFeature> getTestFeatures() {
@@ -57,7 +58,8 @@ public Set<NodeFeature> getTestFeatures() {
5758
SemanticTextFieldMapper.SEMANTIC_TEXT_BIT_VECTOR_SUPPORT,
5859
SemanticTextFieldMapper.SEMANTIC_TEXT_HANDLE_EMPTY_INPUT,
5960
TEST_RULE_RETRIEVER_WITH_INDICES_THAT_DONT_RETURN_RANK_DOCS,
60-
SEMANTIC_TEXT_SUPPORT_CHUNKING_CONFIG
61+
SEMANTIC_TEXT_SUPPORT_CHUNKING_CONFIG,
62+
SEMANTIC_TEXT_MATCH_ALL_HIGHLIGHTER
6163
);
6264
}
6365
}

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

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,133 @@ setup:
336336
- length: { hits.hits.0.highlight.semantic_text_field: 2 }
337337
- match: { hits.hits.0.highlight.semantic_text_field.0: "some test data" }
338338
- match: { hits.hits.0.highlight.semantic_text_field.1: "now with chunks" }
339+
340+
---
341+
"Highlighting with match_all query":
342+
- requires:
343+
cluster_features: "semantic_text.match_all_highlighter"
344+
reason: semantic text field supports match_all query with semantic highlighter, effective from 8.19 and 9.1.0.
345+
346+
- do:
347+
search:
348+
index: test-sparse-index
349+
body:
350+
query:
351+
match_all: {}
352+
highlight:
353+
fields:
354+
body:
355+
type: "semantic"
356+
number_of_fragments: 2
357+
358+
- match: { hits.total.value: 1 }
359+
- match: { hits.hits.0._id: "doc_1" }
360+
- length: { hits.hits.0.highlight.body: 2 }
361+
- 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." }
362+
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
363+
364+
- do:
365+
search:
366+
index: test-dense-index
367+
body:
368+
query:
369+
match_all: {}
370+
highlight:
371+
fields:
372+
body:
373+
type: "semantic"
374+
number_of_fragments: 2
375+
376+
- match: { hits.total.value: 1 }
377+
- match: { hits.hits.0._id: "doc_1" }
378+
- length: { hits.hits.0.highlight.body: 2 }
379+
- 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." }
380+
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
381+
382+
---
383+
"Highlighting with match_all query and multiple field types":
384+
- requires:
385+
cluster_features: "semantic_text.match_all_highlighter"
386+
reason: semantic text field supports match_all query with semantic highlighter, effective from 8.19 and 9.1.0.
387+
388+
- do:
389+
indices.create:
390+
index: test-index-sparse
391+
body:
392+
settings:
393+
index.mapping.semantic_text.use_legacy_format: false
394+
mappings:
395+
properties:
396+
semantic_text_field:
397+
type: semantic_text
398+
inference_id: sparse-inference-id
399+
text_field:
400+
type: text
401+
402+
- do:
403+
index:
404+
index: test-index-sparse
405+
id: doc_1
406+
body:
407+
semantic_text_field: [ "some test data", " ", "now with chunks" ]
408+
text_field: "some test data"
409+
refresh: true
410+
411+
- do:
412+
search:
413+
index: test-index-sparse
414+
body:
415+
query:
416+
match_all: {}
417+
highlight:
418+
fields:
419+
body:
420+
type: "semantic"
421+
number_of_fragments: 2
422+
423+
- match: { hits.total.value: 1 }
424+
- match: { hits.hits.0._id: "doc_1" }
425+
- length: { hits.hits.0.highlight.body: 2 }
426+
- match: { hits.hits.0.highlight.body.0: "some test data" }
427+
- match: { hits.hits.0.highlight.body.1: "now with chunks" }
428+
429+
- do:
430+
indices.create:
431+
index: test-index-dense
432+
body:
433+
settings:
434+
index.mapping.semantic_text.use_legacy_format: false
435+
mappings:
436+
properties:
437+
semantic_text_field:
438+
type: semantic_text
439+
inference_id: sparse-inference-id
440+
text_field:
441+
type: text
442+
443+
- do:
444+
index:
445+
index: test-index-dense
446+
id: doc_1
447+
body:
448+
semantic_text_field: [ "some test data", " ", "now with chunks" ]
449+
text_field: "some test data"
450+
refresh: true
451+
452+
- do:
453+
search:
454+
index: test-index-dense
455+
body:
456+
query:
457+
match_all: {}
458+
highlight:
459+
fields:
460+
body:
461+
type: "semantic"
462+
number_of_fragments: 2
463+
464+
- match: { hits.total.value: 1 }
465+
- match: { hits.hits.0._id: "doc_1" }
466+
- length: { hits.hits.0.highlight.body: 2 }
467+
- match: { hits.hits.0.highlight.body.0: "some test data" }
468+
- match: { hits.hits.0.highlight.body.1: "now with chunks" }

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

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,134 @@ setup:
288288
- length: { hits.hits.0.highlight.semantic_text_field: 2 }
289289
- match: { hits.hits.0.highlight.semantic_text_field.0: "some test data" }
290290
- match: { hits.hits.0.highlight.semantic_text_field.1: "now with chunks" }
291+
292+
---
293+
"Highlighting with match_all query":
294+
- requires:
295+
cluster_features: "semantic_text.match_all_highlighter"
296+
reason: semantic text field supports match_all query with semantic highlighter, effective from 8.19 and 9.1.0.
297+
298+
- do:
299+
search:
300+
index: test-sparse-index
301+
body:
302+
query:
303+
match_all: {}
304+
highlight:
305+
fields:
306+
body:
307+
type: "semantic"
308+
number_of_fragments: 2
309+
310+
- match: { hits.total.value: 1 }
311+
- match: { hits.hits.0._id: "doc_1" }
312+
- length: { hits.hits.0.highlight.body: 2 }
313+
- 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." }
314+
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
315+
316+
- do:
317+
search:
318+
index: test-dense-index
319+
body:
320+
query:
321+
match_all: {}
322+
highlight:
323+
fields:
324+
body:
325+
type: "semantic"
326+
number_of_fragments: 2
327+
328+
- match: { hits.total.value: 1 }
329+
- match: { hits.hits.0._id: "doc_1" }
330+
- length: { hits.hits.0.highlight.body: 2 }
331+
- 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." }
332+
- match: { hits.hits.0.highlight.body.1: "You Know, for Search!" }
333+
334+
---
335+
"Highlighting with match_all query and multiple field types":
336+
- requires:
337+
cluster_features: "semantic_text.match_all_highlighter"
338+
reason: semantic text field supports match_all query with semantic highlighter, effective from 8.19 and 9.1.0.
339+
340+
- do:
341+
indices.create:
342+
index: test-index-sparse
343+
body:
344+
settings:
345+
index.mapping.semantic_text.use_legacy_format: true
346+
mappings:
347+
properties:
348+
semantic_text_field:
349+
type: semantic_text
350+
inference_id: sparse-inference-id
351+
text_field:
352+
type: text
353+
354+
- do:
355+
index:
356+
index: test-index-sparse
357+
id: doc_1
358+
body:
359+
semantic_text_field: [ "some test data", " ", "now with chunks" ]
360+
text_field: "some test data"
361+
refresh: true
362+
363+
- do:
364+
search:
365+
index: test-index-sparse
366+
body:
367+
query:
368+
match_all: {}
369+
highlight:
370+
fields:
371+
body:
372+
type: "semantic"
373+
number_of_fragments: 2
374+
375+
- match: { hits.total.value: 1 }
376+
- match: { hits.hits.0._id: "doc_1" }
377+
- length: { hits.hits.0.highlight.body: 2 }
378+
- match: { hits.hits.0.highlight.body.0: "some test data" }
379+
- match: { hits.hits.0.highlight.body.1: "now with chunks" }
380+
381+
- do:
382+
indices.create:
383+
index: test-index-dense
384+
body:
385+
settings:
386+
index.mapping.semantic_text.use_legacy_format: true
387+
mappings:
388+
properties:
389+
semantic_text_field:
390+
type: semantic_text
391+
inference_id: sparse-inference-id
392+
text_field:
393+
type: text
394+
395+
- do:
396+
index:
397+
index: test-index-dense
398+
id: doc_1
399+
body:
400+
semantic_text_field: [ "some test data", " ", "now with chunks" ]
401+
text_field: "some test data"
402+
refresh: true
403+
404+
- do:
405+
search:
406+
index: test-index-dense
407+
body:
408+
query:
409+
match_all: {}
410+
highlight:
411+
fields:
412+
body:
413+
type: "semantic"
414+
number_of_fragments: 2
415+
416+
- match: { hits.total.value: 1 }
417+
- match: { hits.hits.0._id: "doc_1" }
418+
- length: { hits.hits.0.highlight.body: 2 }
419+
- match: { hits.hits.0.highlight.body.0: "some test data" }
420+
- match: { hits.hits.0.highlight.body.1: "now with chunks" }
421+

0 commit comments

Comments
 (0)