Skip to content

Commit 016e448

Browse files
update yaml tests to expand test scenarios
1 parent 3a5a30f commit 016e448

File tree

3 files changed

+119
-13
lines changed

3 files changed

+119
-13
lines changed

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/45_semantic_text_match.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,31 +287,59 @@ setup:
287287
- skip:
288288
features: [ "headers", "close_to" ]
289289

290+
- do:
291+
indices.create:
292+
index: test-sparse-index-random
293+
body:
294+
settings:
295+
number_of_shards: 1
296+
number_of_replicas: 0
297+
mappings:
298+
properties:
299+
inference_field:
300+
type: semantic_text
301+
inference_id: sparse-inference-id
302+
290303
- do:
291304
index:
292-
index: test-sparse-index
305+
index: test-sparse-index-random
293306
id: doc_1
294307
body:
295-
inference_field: [ "inference test", "another inference test" ]
296-
non_inference_field: "non inference test"
308+
inference_field: [ "It was a beautiful game", "Very competitive" ]
297309
refresh: true
298310

299311
- do:
300312
headers:
301313
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
302314
Content-Type: application/json
303315
search:
304-
index: test-sparse-index
316+
index: test-sparse-index-random
305317
body:
306318
query:
307319
match:
308320
inference_field:
309-
query: "inference test"
321+
query: "soccer"
322+
323+
- match: { hits.total.value: 1 }
324+
- match: { hits.hits.0._id: "doc_1" }
325+
- close_to: { hits.hits.0._score: { value: 5.700229E18, error: 1e15 } }
326+
- not_exists: hits.hits.0.matched_queries
327+
328+
- do:
329+
headers:
330+
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
331+
Content-Type: application/json
332+
search:
333+
index: test-sparse-index-random
334+
body:
335+
query:
336+
match:
337+
inference_field:
338+
query: "soccer"
310339
boost: 5.0
311340
_name: i-like-naming-my-queries
312341

313342
- match: { hits.total.value: 1 }
314343
- match: { hits.hits.0._id: "doc_1" }
315-
- close_to: { hits.hits.0._score: { value: 1.8918664E18, error: 1e15 } }
344+
- close_to: { hits.hits.0._score: { value: 2.8501142E19, error: 1e15 } }
316345
- match: { hits.hits.0.matched_queries: [ "i-like-naming-my-queries" ] }
317-

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/46_semantic_text_sparse_vector.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,27 @@ setup:
256256
- skip:
257257
features: [ "headers", "close_to" ]
258258

259+
- do:
260+
indices.create:
261+
index: test-sparse-index-random
262+
body:
263+
settings:
264+
number_of_shards: 1
265+
number_of_replicas: 0
266+
mappings:
267+
properties:
268+
inference_field:
269+
type: semantic_text
270+
inference_id: sparse-inference-id
271+
272+
- do:
273+
index:
274+
index: test-sparse-index-random
275+
id: doc_1
276+
body:
277+
inference_field: [ "It was a beautiful game", "Very competitive" ]
278+
refresh: true
279+
259280
- do:
260281
headers:
261282
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
@@ -266,13 +287,28 @@ setup:
266287
query:
267288
sparse_vector:
268289
field: inference_field
269-
query: "inference test"
290+
query: "soccer"
291+
292+
- match: { hits.total.value: 1 }
293+
- match: { hits.hits.0._id: "doc_1" }
294+
- close_to: { hits.hits.0._score: { value: 6.9606755E18, error: 1e15 } }
295+
- not_exists: hits.hits.0.matched_queries
296+
297+
- do:
298+
headers:
299+
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
300+
Content-Type: application/json
301+
search:
302+
index: test-sparse-index-random
303+
body:
304+
query:
305+
sparse_vector:
306+
field: inference_field
307+
query: "soccer"
270308
boost: 5.0
271309
_name: i-like-naming-my-queries
272310

273311
- match: { hits.total.value: 1 }
274312
- match: { hits.hits.0._id: "doc_1" }
275-
- close_to: { hits.hits.0._score: { value: 1.8918664E18, error: 1e15 } }
313+
- close_to: { hits.hits.0._score: { value: 2.8501142E19, error: 1e15 } }
276314
- match: { hits.hits.0.matched_queries: [ "i-like-naming-my-queries" ] }
277-
278-

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/47_semantic_text_knn.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,27 @@ setup:
413413
- skip:
414414
features: [ "headers", "close_to" ]
415415

416+
- do:
417+
indices.create:
418+
index: test-sparse-index-random
419+
body:
420+
settings:
421+
number_of_shards: 1
422+
number_of_replicas: 0
423+
mappings:
424+
properties:
425+
inference_field:
426+
type: semantic_text
427+
inference_id: dense-inference-id
428+
429+
- do:
430+
index:
431+
index: test-sparse-index-random
432+
id: doc_1
433+
body:
434+
inference_field: [ "It was a beautiful game", "Very competitive" ]
435+
refresh: true
436+
416437
- do:
417438
headers:
418439
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
@@ -427,13 +448,34 @@ setup:
427448
num_candidates: 100
428449
query_vector_builder:
429450
text_embedding:
430-
model_text: test
451+
model_text: soccer
452+
453+
- match: { hits.total.value: 1 }
454+
- match: { hits.hits.0._id: "doc_1" }
455+
- close_to: { hits.hits.0._score: { value: 0.9984111, error: 1e15 } }
456+
- not_exists: hits.hits.0.matched_queries
457+
458+
- do:
459+
headers:
460+
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
461+
Content-Type: application/json
462+
search:
463+
index: test-sparse-index-random
464+
body:
465+
query:
466+
knn:
467+
field: inference_field
468+
k: 2
469+
num_candidates: 100
470+
query_vector_builder:
471+
text_embedding:
472+
model_text: soccer
431473
boost: 5.0
432474
_name: i-like-naming-my-queries
433475

434476
- match: { hits.total.value: 1 }
435477
- match: { hits.hits.0._id: "doc_1" }
436-
- close_to: { hits.hits.0._score: { value: 4.7153287, error: 1e13 } }
478+
- close_to: { hits.hits.0._score: { value: 4.9907494, error: 1e15 } }
437479
- match: { hits.hits.0.matched_queries: [ "i-like-naming-my-queries" ] }
438480

439481

0 commit comments

Comments
 (0)