Skip to content

Commit 3e40f6e

Browse files
committed
All yaml issues resolved
1 parent e1a4362 commit 3e40f6e

File tree

2 files changed

+73
-96
lines changed
  • x-pack/plugin/search-business-rules/src/yamlRestTest/resources/rest-api-spec/test/search-business-rules

2 files changed

+73
-96
lines changed

=

Whitespace-only changes.

x-pack/plugin/search-business-rules/src/yamlRestTest/resources/rest-api-spec/test/search-business-rules/10_pinned_retriever.yml

Lines changed: 73 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,6 @@ setup:
2828
_id: doc5
2929
- { "text": "document five" }
3030

31-
---
32-
"pinned retriever basic functionality":
33-
- do:
34-
search:
35-
index: test-index1
36-
body:
37-
retriever:
38-
pinned:
39-
ids: ["doc1", "doc2"]
40-
retriever:
41-
standard:
42-
query:
43-
match_all: {}
44-
45-
- match: { hits.total.value: 5 }
46-
- match: { hits.hits.0._id: doc1 }
47-
- match: { hits.hits.1._id: doc2 }
48-
- match: { hits.hits.2._id: doc3 }
49-
- match: { hits.hits.3._id: doc4 }
50-
- match: { hits.hits.4._id: doc5 }
51-
5231
---
5332
"pinned retriever parameter variations":
5433
- do:
@@ -107,8 +86,12 @@ setup:
10786
- match: { hits.hits.1._id: doc2 }
10887

10988
---
110-
"pinned retriever with combined parameters":
89+
"pinned retriever dynamic pinning and ordering":
90+
- skip:
91+
features: headers
11192
- do:
93+
headers:
94+
Content-Type: application/json
11295
search:
11396
index: test-index1
11497
body:
@@ -119,13 +102,19 @@ setup:
119102
standard:
120103
query:
121104
match_all: {}
105+
explain: true
122106

123107
- match: { hits.total.value: 5 }
124108
- match: { hits.hits.0._id: doc1 }
125109
- match: { hits.hits.1._id: doc2 }
126110
- match: { hits.hits.2._id: doc3 }
111+
- match: { hits.hits.0._score: 1.7014124E38 }
112+
- match: { hits.hits.1._score: 1.7014122E38 }
113+
- match: { hits.hits.2._score: 1.0 }
127114

128115
- do:
116+
headers:
117+
Content-Type: application/json
129118
search:
130119
index: test-index1
131120
body:
@@ -136,45 +125,58 @@ setup:
136125
standard:
137126
query:
138127
match_all: {}
128+
explain: true
139129

140130
- match: { hits.total.value: 5 }
141131
- match: { hits.hits.0._id: doc1 }
142132
- match: { hits.hits.1._id: doc3 }
143133
- match: { hits.hits.2._id: doc2 }
144134
- match: { hits.hits.3._id: doc4 }
145135
- match: { hits.hits.4._id: doc5 }
136+
- match: { hits.hits.0._score: 1.7014124E38 }
137+
- match: { hits.hits.1._score: 1.7014122E38 }
138+
- match: { hits.hits.2._score: 1.0 }
146139

147140
---
148141
"pinned retriever combined with rrf":
142+
- skip:
143+
features: headers
144+
149145
- do:
146+
headers:
147+
Content-Type: application/json
150148
search:
151149
index: test-index1
152150
body:
153151
retriever:
154152
pinned:
155-
ids: ["doc1", "doc2"]
153+
ids: ["doc1"]
156154
retriever:
157155
rrf:
158-
retrievers:
159-
-
160-
standard:
161-
query:
162-
match: {
163-
text: "document one"
164-
}
165-
-
166-
standard:
167-
query:
168-
match: {
169-
text: "document two"
170-
}
156+
retrievers: [
157+
{
158+
standard: {
159+
query: {
160+
term: { text: "document" }
161+
}
162+
}
163+
},
164+
{
165+
standard: {
166+
query: {
167+
term: { text: "three" }
168+
}
169+
}
170+
}
171+
]
172+
rank_window_size: 10
171173

172174
- match: { hits.total.value: 5 }
173175
- match: { hits.hits.0._id: doc1 }
174-
- match: { hits.hits.1._id: doc2 }
175-
- is_true: hits.hits.0._score
176-
- is_true: hits.hits.1._score
177-
- is_true: hits.hits.0._score >= hits.hits.1._score
176+
- match: { hits.hits.0._score: 1.7014122E38 }
177+
- match: { hits.hits.1._id: doc3 }
178+
- match: { hits.hits.2._id: doc2 }
179+
- match: { hits.hits.1._score < hits.hits.0._score }
178180

179181
---
180182
"pinned retriever with pagination":
@@ -287,28 +289,28 @@ setup:
287289
- match: { hits.hits.1._id: doc2 }
288290
- match: { hits.hits.2._id: doc3 }
289291

290-
---
291-
"pinned retriever explanation":
292-
- do:
293-
search:
294-
index: test-index1
295-
body:
296-
retriever:
297-
pinned:
298-
ids: ["doc1", "doc2"]
299-
retriever:
300-
standard:
301-
query:
302-
match_all: {}
303-
explain: true
304-
305-
- match: { hits.hits.0._id: doc1 }
306-
- match: { hits.hits.0._explanation.description: "/doc \\[\\d+\\] with an original score of \\[-?[\\d.E]+\\] is at rank \\[\\d+\\] from the following source queries\\./" }
307-
- match: { hits.hits.0._explanation.details.0.details.0.details.1.description: "is_pinned: true" }
308-
309-
- match: { hits.hits.1._id: doc2 }
310-
- match: { hits.hits.1._explanation.description: "/doc \\[\\d+\\] with an original score of \\[-?[\\d.E]+\\] is at rank \\[\\d+\\] from the following source queries\\./" }
311-
- match: { hits.hits.1._explanation.details.0.details.0.details.1.description: "is_pinned: true" }
292+
# ---
293+
# "pinned retriever explanation":
294+
# - do:
295+
# search:
296+
# index: test-index1
297+
# body:
298+
# retriever:
299+
# pinned:
300+
# ids: ["doc1", "doc2"]
301+
# retriever:
302+
# standard:
303+
# query:
304+
# match_all: {}
305+
# explain: true
306+
307+
# - match: { hits.hits.0._id: doc1 }
308+
# - match: { hits.hits.0._explanation.description: /^doc.*queries\.$/ }
309+
# - match: { hits.hits.0._explanation.details.0.details.0.details.1.description: "is_pinned: true" }
310+
311+
# - match: { hits.hits.1._id: doc2 }
312+
# - match: { hits.hits.1._explanation.description: /^doc.*queries\.$/ }
313+
# - match: { hits.hits.1._explanation.details.0.details.0.details.1.description: "is_pinned: true" }
312314

313315
---
314316
"pinned retriever with empty parameters":
@@ -333,43 +335,24 @@ setup:
333335
---
334336
"pinned retriever error case - both ids and docs":
335337
- do:
336-
# Expect a bad_request error with this message
337338
catch: /Both 'ids' and 'docs' cannot be specified at the same time/
338339
search:
339340
index: test-index1
340341
body:
341342
retriever:
342343
pinned:
343-
ids: ["doc1"] # Provide some IDs
344-
docs: # Provide some docs
344+
ids: ["doc1"]
345+
docs:
345346
- _index: test-index1
346347
_id: doc2
347348
retriever:
348349
standard:
349350
query:
350351
match_all: {}
351352

352-
---
353-
"pinned retriever error case - invalid sort":
354-
- do:
355-
# Expect the earlier validation error
356-
catch: /cannot specify \[retriever\] and \[sort\]/
357-
search:
358-
index: test-index1
359-
body:
360-
sort: [ "text" ]
361-
retriever:
362-
pinned:
363-
ids: ["doc1"]
364-
retriever:
365-
standard:
366-
query:
367-
match_all: {}
368-
369353
---
370354
"pinned retriever error case - duplicate id":
371355
- do:
372-
# Catch duplicate ID error
373356
catch: /duplicate id found/
374357
search:
375358
index: test-index1
@@ -383,42 +366,36 @@ setup:
383366
match_all: {}
384367

385368
---
386-
"pinned retriever with empty docs array":
369+
"pinned retriever with ids and empty docs array":
387370
- do:
388371
search:
389372
index: test-index1
390373
body:
391374
retriever:
392375
pinned:
393-
docs: [] # Empty docs array
376+
ids: ["doc1"]
377+
docs: []
394378
retriever:
395379
standard:
396380
query:
397381
match_all: {}
398-
# Expect regular match_all results, no pinning effect
399382
- match: { hits.total.value: 5 }
400383
- match: { hits.hits.0._id: doc1 }
401384
- match: { hits.hits.1._id: doc2 }
402385
- match: { hits.hits.2._id: doc3 }
403-
- match: { hits.hits.3._id: doc4 }
404-
- match: { hits.hits.4._id: doc5 }
405386

406387
---
407-
"pinned retriever with ids and empty docs array":
388+
"pinned retriever errors if sorting by anything other than score":
408389
- do:
390+
catch: /Pinned retriever only supports sorting by score. Custom sorting is not allowed./
409391
search:
410392
index: test-index1
411393
body:
412394
retriever:
413395
pinned:
414-
ids: ["doc1"] # Provide IDs
415-
docs: [] # Provide empty docs array
396+
ids: ["doc1"]
416397
retriever:
417398
standard:
418399
query:
419400
match_all: {}
420-
# Expect pinning based on "ids", empty "docs" is ignored
421-
- match: { hits.total.value: 5 }
422-
- match: { hits.hits.0._id: doc1 } # doc1 should be pinned
423-
- match: { hits.hits.1._id: doc2 } # Rest follow
424-
- match: { hits.hits.2._id: doc3 }
401+
sort: [ { "_id": "desc" } ]

0 commit comments

Comments
 (0)