Skip to content

Commit 768b8f6

Browse files
fix yaml tests with 4 digits error margin
1 parent 394f43a commit 768b8f6

File tree

3 files changed

+46
-198
lines changed

3 files changed

+46
-198
lines changed

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

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -287,33 +287,21 @@ 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-
303290
- do:
304291
index:
305-
index: test-sparse-index-random
292+
index: test-sparse-index
306293
id: doc_1
307294
body:
308295
inference_field: [ "It was a beautiful game", "Very competitive" ]
296+
non_inference_field: "non inference test"
309297
refresh: true
310298

311299
- do:
312300
headers:
313301
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
314302
Content-Type: application/json
315303
search:
316-
index: test-sparse-index-random
304+
index: test-sparse-index
317305
body:
318306
query:
319307
match:
@@ -322,15 +310,15 @@ setup:
322310

323311
- match: { hits.total.value: 1 }
324312
- match: { hits.hits.0._id: "doc_1" }
325-
- close_to: { hits.hits.0._score: { value: 5.700229E18, error: 1e-7 } }
313+
- close_to: { hits.hits.0._score: { value: 5.700229E18, error: 1e15 } }
326314
- not_exists: hits.hits.0.matched_queries
327315

328316
- do:
329317
headers:
330318
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
331319
Content-Type: application/json
332320
search:
333-
index: test-sparse-index-random
321+
index: test-sparse-index
334322
body:
335323
query:
336324
match:
@@ -341,7 +329,7 @@ setup:
341329

342330
- match: { hits.total.value: 1 }
343331
- match: { hits.hits.0._id: "doc_1" }
344-
- close_to: { hits.hits.0._score: { value: 2.8501142E19, error: 1e-7 } }
332+
- close_to: { hits.hits.0._score: { value: 2.8501142E19, error: 1e16 } }
345333
- match: { hits.hits.0.matched_queries: [ "i-like-naming-my-queries" ] }
346334

347335
---
@@ -353,50 +341,30 @@ setup:
353341
- skip:
354342
features: [ "headers", "close_to" ]
355343

356-
- do:
357-
indices.create:
358-
index: index-with-semantic-field
359-
body:
360-
settings:
361-
number_of_shards: 1
362-
number_of_replicas: 0
363-
mappings:
364-
properties:
365-
inference_field:
366-
type: semantic_text
367-
inference_id: sparse-inference-id
368-
369-
- do:
370-
indices.create:
371-
index: index-with-text-field
372-
body:
373-
mappings:
374-
properties:
375-
inference_field:
376-
type: text
377-
378344
- do:
379345
index:
380-
index: index-with-semantic-field
346+
index: test-sparse-index
381347
id: doc_1
382348
body:
383349
inference_field: [ "It was a beautiful game", "Very competitive" ]
350+
non_inference_field: "non inference test"
384351
refresh: true
385352

386353
- do:
387354
index:
388-
index: index-with-text-field
355+
index: test-text-only-index
389356
id: doc_2
390357
body:
391358
inference_field: [ "It was a beautiful game", "Very competitive" ]
359+
non_inference_field: "non inference test"
392360
refresh: true
393361

394362
- do:
395363
headers:
396364
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
397365
Content-Type: application/json
398366
search:
399-
index: index-with-semantic-field,index-with-text-field
367+
index: test-sparse-index,test-text-only-index
400368
body:
401369
query:
402370
match:
@@ -406,17 +374,17 @@ setup:
406374
- match: { hits.total.value: 2 }
407375
- match: { hits.hits.0._id: "doc_1" }
408376
- match: { hits.hits.1._id: "doc_2" }
409-
- close_to: { hits.hits.0._score: { value: 1.1140361E19, error: 1e-7 } }
377+
- close_to: { hits.hits.0._score: { value: 1.1140361E19, error: 1e16 } }
410378
- not_exists: hits.hits.0.matched_queries
411-
- close_to: { hits.hits.1._score: { value: 0.2876821, error: 1e-7 } }
379+
- close_to: { hits.hits.1._score: { value: 0.2876821, error: 1e-4 } }
412380
- not_exists: hits.hits.1.matched_queries
413381

414382
- do:
415383
headers:
416384
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
417385
Content-Type: application/json
418386
search:
419-
index: index-with-semantic-field,index-with-text-field
387+
index: test-sparse-index,test-text-only-index
420388
body:
421389
query:
422390
match:
@@ -428,7 +396,7 @@ setup:
428396
- match: { hits.total.value: 2 }
429397
- match: { hits.hits.0._id: "doc_1" }
430398
- match: { hits.hits.1._id: "doc_2" }
431-
- close_to: { hits.hits.0._score: { value: 5.5701804E19, error: 1e-7 } }
399+
- close_to: { hits.hits.0._score: { value: 5.5701804E19, error: 1e16 } }
432400
- match: { hits.hits.0.matched_queries: [ "i-like-naming-my-queries" ] }
433-
- close_to: { hits.hits.1._score: { value: 1.4384103, error: 1e-7 } }
401+
- close_to: { hits.hits.1._score: { value: 1.4384103, error: 1e-4 } }
434402
- match: { hits.hits.1.matched_queries: [ "i-like-naming-my-queries" ] }

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

Lines changed: 14 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -256,61 +256,40 @@ 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-
280259
- do:
281260
headers:
282261
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
283262
Content-Type: application/json
284263
search:
285-
index: test-sparse-index-random
264+
index: test-semantic-text-index
286265
body:
287266
query:
288267
sparse_vector:
289268
field: inference_field
290-
query: "soccer"
269+
query: "inference test"
291270

292271
- match: { hits.total.value: 1 }
293272
- match: { hits.hits.0._id: "doc_1" }
294-
- close_to: { hits.hits.0._score: { value: 5.700229E18, error: 1e-7 } }
273+
- close_to: { hits.hits.0._score: { value: 3.7837332E17, error: 1e14 } }
295274
- not_exists: hits.hits.0.matched_queries
296275

297276
- do:
298277
headers:
299278
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
300279
Content-Type: application/json
301280
search:
302-
index: test-sparse-index-random
281+
index: test-semantic-text-index
303282
body:
304283
query:
305284
sparse_vector:
306285
field: inference_field
307-
query: "soccer"
286+
query: "inference test"
308287
boost: 5.0
309288
_name: i-like-naming-my-queries
310289

311290
- match: { hits.total.value: 1 }
312291
- match: { hits.hits.0._id: "doc_1" }
313-
- close_to: { hits.hits.0._score: { value: 2.8501142E19, error: 1e-7 } }
292+
- close_to: { hits.hits.0._score: { value: 1.8918664E18, error: 1e15 } }
314293
- match: { hits.hits.0.matched_queries: [ "i-like-naming-my-queries" ] }
315294

316295
---
@@ -322,84 +301,46 @@ setup:
322301
- skip:
323302
features: [ "headers", "close_to" ]
324303

325-
- do:
326-
indices.create:
327-
index: index-with-semantic-field
328-
body:
329-
settings:
330-
number_of_shards: 1
331-
number_of_replicas: 0
332-
mappings:
333-
properties:
334-
inference_field:
335-
type: semantic_text
336-
inference_id: sparse-inference-id
337-
338-
- do:
339-
indices.create:
340-
index: index-with-sparse-field
341-
body:
342-
mappings:
343-
properties:
344-
inference_field:
345-
type: sparse_vector
346-
347-
- do:
348-
index:
349-
index: index-with-semantic-field
350-
id: doc_1
351-
body:
352-
inference_field: [ "It was a beautiful game", "Very competitive" ]
353-
refresh: true
354-
355-
- do:
356-
index:
357-
index: index-with-sparse-field
358-
id: doc_2
359-
body:
360-
inference_field: { "feature_0": 1, "feature_1": 2, "feature_2": 3, "feature_3": 4, "feature_4": 5 }
361-
refresh: true
362-
363304
- do:
364305
headers:
365306
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
366307
Content-Type: application/json
367308
search:
368-
index: index-with-semantic-field,index-with-sparse-field
309+
index: test-semantic-text-index,test-sparse-vector-index
369310
body:
370311
query:
371312
sparse_vector:
372313
field: inference_field
373-
query: "soccer"
314+
query: "inference test"
374315
inference_id: sparse-inference-id
375316

376317
- match: { hits.total.value: 2 }
377318
- match: { hits.hits.0._id: "doc_1" }
378319
- match: { hits.hits.1._id: "doc_2" }
379-
- close_to: { hits.hits.0._score: { value: 5.700229E18, error: 1e-7 } }
320+
- close_to: { hits.hits.0._score: { value: 3.7837332E17, error: 1e14 } }
380321
- not_exists: hits.hits.0.matched_queries
381-
- close_to: { hits.hits.1._score: { value: 1.3455845E10, error: 1e-7 } }
322+
- close_to: { hits.hits.1._score: { value: 7.314424E8, error: 1e5 } }
382323
- not_exists: hits.hits.1.matched_queries
383324

384325
- do:
385326
headers:
386327
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
387328
Content-Type: application/json
388329
search:
389-
index: index-with-semantic-field,index-with-sparse-field
330+
index: test-semantic-text-index,test-sparse-vector-index
390331
body:
391332
query:
392333
sparse_vector:
393334
field: inference_field
394-
query: "soccer"
335+
query: "inference test"
395336
inference_id: sparse-inference-id
396337
boost: 5.0
397338
_name: i-like-naming-my-queries
398339

399340
- match: { hits.total.value: 2 }
400341
- match: { hits.hits.0._id: "doc_1" }
401342
- match: { hits.hits.1._id: "doc_2" }
402-
- close_to: { hits.hits.0._score: { value: 2.8501142E19, error: 1e-7 } }
343+
- close_to: { hits.hits.0._score: { value: 1.8918664E18, error: 1e15 } }
403344
- match: { hits.hits.0.matched_queries: [ "i-like-naming-my-queries" ] }
404-
- close_to: { hits.hits.1._score: { value: 6.7279225E10, error: 1e-7 } }
345+
- close_to: { hits.hits.1._score: { value: 3.657212E9, error: 1e6 } }
405346
- match: { hits.hits.1.matched_queries: [ "i-like-naming-my-queries" ] }

0 commit comments

Comments
 (0)