Skip to content

Commit 1d4eb6f

Browse files
committed
Explanation yaml files added
1 parent 3e40f6e commit 1d4eb6f

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilder.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,12 @@ private void validateSort(SearchSourceBuilder source) {
100100
continue;
101101
}
102102
if (sort instanceof FieldSortBuilder) {
103-
FieldSortBuilder fieldSort = (FieldSortBuilder) sort;
104-
if (ShardDocSortField.NAME.equals(fieldSort.getFieldName())) {
105-
continue;
106-
}
103+
FieldSortBuilder fieldSort = (FieldSortBuilder) sort;
104+
if (ShardDocSortField.NAME.equals(fieldSort.getFieldName())) {
105+
continue;
106+
}
107107
}
108-
throw new IllegalArgumentException(
109-
"Pinned retriever only supports sorting by score. Custom sorting is not allowed."
110-
);
108+
throw new IllegalArgumentException("Pinned retriever only supports sorting by score. Custom sorting is not allowed.");
111109
}
112110
}
113111

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -289,28 +289,33 @@ setup:
289289
- match: { hits.hits.1._id: doc2 }
290290
- match: { hits.hits.2._id: doc3 }
291291

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" }
292+
---
293+
"pinned retriever explanation":
294+
- skip:
295+
features: headers
296+
297+
- do:
298+
headers:
299+
Content-Type: application/json
300+
search:
301+
index: test-index1
302+
body:
303+
retriever:
304+
pinned:
305+
ids: ["doc1", "doc2"]
306+
retriever:
307+
standard:
308+
query:
309+
match_all: {}
310+
explain: true
311+
312+
- match: { hits.hits.0._id: doc1 }
313+
- match: { hits.hits.0._explanation.value: 1.0 }
314+
- match: { hits.hits.0._explanation.description: "doc [0] with an original score of [1.7014124E38] is at rank [1] from the following source queries." }
315+
316+
- match: { hits.hits.1._id: doc2 }
317+
- match: { hits.hits.1._explanation.value: 2.0 }
318+
- match: { hits.hits.1._explanation.description: "doc [1] with an original score of [1.7014122E38] is at rank [2] from the following source queries." }
314319

315320
---
316321
"pinned retriever with empty parameters":

0 commit comments

Comments
 (0)