Skip to content

Commit 9cb6b90

Browse files
author
Christoph Büscher
authored
[Tests] Move templated _rank_eval tests (#30679)
This change moves the ranking evaluation tests that use templates to the existing yml rest tests instead of extending ESIntegTestCase. Closes #30628
1 parent 2b8d3e8 commit 9cb6b90

File tree

4 files changed

+171
-234
lines changed

4 files changed

+171
-234
lines changed

qa/smoke-test-rank-eval-with-mustache/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,3 @@ dependencies {
3131
* and will be fixed later.
3232
* Tracked by https://github.com/elastic/elasticsearch/issues/30628
3333
*/
34-
if ("zip".equals(integTestCluster.distribution)) {
35-
integTestRunner.enabled = false
36-
}

qa/smoke-test-rank-eval-with-mustache/src/test/java/org/elasticsearch/index/rankeval/SmokeMultipleTemplatesIT.java

Lines changed: 0 additions & 159 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
setup:
2+
3+
- do:
4+
indices.create:
5+
index: test
6+
body:
7+
settings:
8+
index:
9+
number_of_shards: 1
10+
- do:
11+
index:
12+
index: test
13+
type: _doc
14+
id: 1
15+
body: { "text": "berlin", "title" : "Berlin, Germany" }
16+
17+
- do:
18+
index:
19+
index: test
20+
type: _doc
21+
id: 2
22+
body: { "text": "amsterdam" }
23+
24+
- do:
25+
index:
26+
index: test
27+
type: _doc
28+
id: 3
29+
body: { "text": "amsterdam" }
30+
31+
- do:
32+
index:
33+
index: test
34+
type: _doc
35+
id: 4
36+
body: { "text": "amsterdam" }
37+
38+
- do:
39+
index:
40+
index: test
41+
type: _doc
42+
id: 5
43+
body: { "text": "amsterdam" }
44+
45+
- do:
46+
index:
47+
index: test
48+
type: _doc
49+
id: 6
50+
body: { "text": "amsterdam" }
51+
52+
- do:
53+
indices.refresh: {}
54+
55+
---
56+
"Basic rank-eval request with template":
57+
58+
- skip:
59+
version: " - 6.1.99"
60+
reason: the ranking evaluation feature is available since 6.2
61+
62+
- do:
63+
rank_eval:
64+
body: {
65+
"templates": [ { "id": "match", "template": {"source": "{\"query\": { \"match\" : {\"text\" : \"{{query_string}}\" }}}" }} ],
66+
"requests" : [
67+
{
68+
"id": "amsterdam_query",
69+
"params": { "query_string": "amsterdam" },
70+
"template_id": "match",
71+
"ratings": [
72+
{"_index": "test", "_id": "2", "rating": 1},
73+
{"_index": "test", "_id": "3", "rating": 1},
74+
{"_index": "test", "_id": "4", "rating": 1},
75+
{"_index": "test", "_id": "5", "rating": 1},]
76+
},
77+
{
78+
"id" : "berlin_query",
79+
"params": { "query_string": "berlin" },
80+
"template_id": "match",
81+
"ratings": [{"_index": "test", "_id": "1", "rating": 1}]
82+
}
83+
],
84+
"metric" : { "precision": { }}
85+
}
86+
87+
- match: {quality_level: 0.9}
88+
- match: {details.amsterdam_query.unknown_docs.0._id: "6"}
89+
90+
---
91+
"Test illegal request parts":
92+
93+
- do:
94+
catch: /Query in rated requests should not contain aggregations./
95+
rank_eval:
96+
body: {
97+
"templates": [ { "id": "match", "template": {"source": "{ \"aggs\" : { \"avg_grade\" : { \"avg\" : { \"field\" : \"grade\" }}}}" }} ],
98+
"requests" : [
99+
{
100+
"id": "amsterdam_query",
101+
"params": { "query_string": "amsterdam" },
102+
"template_id": "match",
103+
"ratings": []
104+
}
105+
],
106+
"metric" : { "precision": { }}
107+
}
108+
109+
- do:
110+
catch: /Query in rated requests should not contain a suggest section./
111+
rank_eval:
112+
body: {
113+
"templates": [ { "id": "match", "template": {"source": "{\"suggest\" : {\"my-suggestion\" : {\"text\" : \"Elastic\",\"term\" : {\"field\" : \"message\"}}}}" }} ],
114+
"requests" : [
115+
{
116+
"id": "amsterdam_query",
117+
"params": { "query_string": "amsterdam" },
118+
"template_id": "match",
119+
"ratings": []
120+
}
121+
],
122+
"metric" : { "precision": { }}
123+
}
124+
125+
- do:
126+
catch: /Query in rated requests should not contain a highlighter section./
127+
rank_eval:
128+
body: {
129+
"templates": [ { "id": "match", "template": {"source": "{\"highlight\" : { \"fields\" : {\"content\" : {}}}}" }} ],
130+
"requests" : [
131+
{
132+
"id": "amsterdam_query",
133+
"params": { "query_string": "amsterdam" },
134+
"template_id": "match",
135+
"ratings": []
136+
}
137+
],
138+
"metric" : { "precision": { }}
139+
}
140+
141+
- do:
142+
catch: /Query in rated requests should not use profile./
143+
rank_eval:
144+
body: {
145+
"templates": [ { "id": "match", "template": {"source": "{\"profile\" : \"true\" }" }} ],
146+
"requests" : [
147+
{
148+
"id": "amsterdam_query",
149+
"params": { "query_string": "amsterdam" },
150+
"template_id": "match",
151+
"ratings": []
152+
}
153+
],
154+
"metric" : { "precision": { }}
155+
}
156+
157+
- do:
158+
catch: /Query in rated requests should not use explain./
159+
rank_eval:
160+
body: {
161+
"templates": [ { "id": "match", "template": {"source": "{\"explain\" : \"true\" }" }} ],
162+
"requests" : [
163+
{
164+
"id": "amsterdam_query",
165+
"params": { "query_string": "amsterdam" },
166+
"template_id": "match",
167+
"ratings": []
168+
}
169+
],
170+
"metric" : { "precision": { }}
171+
}

0 commit comments

Comments
 (0)