Skip to content

Commit 26ae289

Browse files
authored
Fix reranker tests (#126500)
1 parent 595ba6b commit 26ae289

File tree

3 files changed

+41
-62
lines changed

3 files changed

+41
-62
lines changed

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClusterSpecIT.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
5353
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_PLANNING_V1;
5454
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
55-
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.RERANK;
5655
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.UNMAPPED_FIELDS;
5756
import static org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase.Mode.SYNC;
5857
import static org.mockito.ArgumentMatchers.any;
@@ -131,8 +130,6 @@ protected void shouldSkipTest(String testName) throws IOException {
131130
assumeFalse("LOOKUP JOIN not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_LOOKUP_V12.capabilityName()));
132131
// Unmapped fields require a coorect capability response from every cluster, which isn't currently implemented.
133132
assumeFalse("UNMAPPED FIELDS not yet supported in CCS", testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName()));
134-
// Need to do additional developmnet to get CSS support for the rerank coammnd
135-
assumeFalse("RERANK not yet supported in CCS", testCase.requiredCapabilities.contains(RERANK.capabilityName()));
136133
}
137134

138135
@Override

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.util.stream.Collectors;
5252
import java.util.stream.IntStream;
5353
import java.util.stream.LongStream;
54+
import java.util.stream.Stream;
5455

5556
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLatitude;
5657
import static org.apache.lucene.geo.GeoEncodingUtils.decodeLongitude;
@@ -74,6 +75,8 @@
7475
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;
7576
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
7677
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METRICS_COMMAND;
78+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.RERANK;
79+
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SEMANTIC_TEXT_FIELD_CAPS;
7780
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.SOURCE_FIELD_MAPPING;
7881

7982
// This test can run very long in serverless configurations
@@ -177,8 +180,8 @@ public final void test() throws Throwable {
177180
}
178181

179182
protected void shouldSkipTest(String testName) throws IOException {
180-
if (testCase.requiredCapabilities.contains("semantic_text_field_caps") || testCase.requiredCapabilities.contains("rerank")) {
181-
assumeTrue("Inference test service needs to be supported for semantic_text", supportsInferenceTestService());
183+
if (requiresInferenceEndpoint()) {
184+
assumeTrue("Inference test service needs to be supported", supportsInferenceTestService());
182185
}
183186
checkCapabilities(adminClient(), testFeatureService, testName, testCase);
184187
assumeTrue("Test " + testName + " is not enabled", isEnabled(testName, instructions, Version.CURRENT));
@@ -248,6 +251,11 @@ protected boolean supportsInferenceTestService() {
248251
return true;
249252
}
250253

254+
protected boolean requiresInferenceEndpoint() {
255+
return Stream.of(SEMANTIC_TEXT_FIELD_CAPS.capabilityName(), RERANK.capabilityName())
256+
.anyMatch(testCase.requiredCapabilities::contains);
257+
}
258+
251259
protected boolean supportsIndexModeLookup() throws IOException {
252260
return true;
253261
}

x-pack/plugin/esql/qa/testFixtures/src/main/resources/rerank.csv-spec

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ required_capability: match_operator_colon
1010
FROM books METADATA _score
1111
| WHERE title:"war and peace" AND author:"Tolstoy"
1212
| RERANK "war and peace" ON title WITH test_reranker
13-
| KEEP book_no, title, author, _score
14-
| EVAL _score = ROUND(_score, 5)
13+
| KEEP book_no, title, author
1514
;
1615

17-
book_no:keyword | title:text | author:text | _score:double
18-
5327 | War and Peace | Leo Tolstoy | 0.03846
19-
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222
20-
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083
21-
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.01515
16+
book_no:keyword | title:text | author:text
17+
5327 | War and Peace | Leo Tolstoy
18+
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy]
19+
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo
20+
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy
2221
;
2322

2423

@@ -29,15 +28,14 @@ required_capability: match_operator_colon
2928
FROM books METADATA _score
3029
| WHERE title:"war and peace" AND author:"Tolstoy"
3130
| RERANK "war and peace" ON title, author WITH test_reranker
32-
| KEEP book_no, title, author, _score
33-
| EVAL _score = ROUND(_score, 5)
31+
| KEEP book_no, title, author
3432
;
3533

36-
book_no:keyword | title:text | author:text | _score:double
37-
5327 | War and Peace | Leo Tolstoy | 0.02083
38-
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.01429
39-
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.01136
40-
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.00952
34+
book_no:keyword | title:text | author:text
35+
5327 | War and Peace | Leo Tolstoy
36+
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo
37+
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy
38+
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy]
4139
;
4240

4341

@@ -50,14 +48,13 @@ FROM books METADATA _score
5048
| SORT _score DESC
5149
| LIMIT 3
5250
| RERANK "war and peace" ON title WITH test_reranker
53-
| KEEP book_no, title, author, _score
54-
| EVAL _score = ROUND(_score, 5)
51+
| KEEP book_no, title, author
5552
;
5653

57-
book_no:keyword | title:text | author:text | _score:double
58-
5327 | War and Peace | Leo Tolstoy | 0.03846
59-
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222
60-
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083
54+
book_no:keyword | title:text | author:text
55+
5327 | War and Peace | Leo Tolstoy
56+
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy]
57+
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo
6158
;
6259

6360

@@ -68,35 +65,14 @@ required_capability: match_operator_colon
6865
FROM books METADATA _score
6966
| WHERE title:"war and peace" AND author:"Tolstoy"
7067
| RERANK "war and peace" ON title WITH test_reranker
71-
| KEEP book_no, title, author, _score
68+
| KEEP book_no, title, author
7269
| LIMIT 3
73-
| EVAL _score = ROUND(_score, 5)
7470
;
7571

76-
book_no:keyword | title:text | author:text | _score:double
77-
5327 | War and Peace | Leo Tolstoy | 0.03846
78-
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222
79-
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083
80-
;
81-
82-
83-
reranker add the _score column when missing
84-
required_capability: rerank
85-
required_capability: match_operator_colon
86-
87-
FROM books
88-
| WHERE title:"war and peace" AND author:"Tolstoy"
89-
| RERANK "war and peace" ON title WITH test_reranker
90-
| KEEP book_no, title, author, _score
91-
| EVAL _score = ROUND(_score, 5)
92-
;
93-
94-
95-
book_no:keyword | title:text | author:text | _score:double
96-
5327 | War and Peace | Leo Tolstoy | 0.03846
97-
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222
98-
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo | 0.02083
99-
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.01515
72+
book_no:keyword | title:text | author:text
73+
5327 | War and Peace | Leo Tolstoy
74+
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy]
75+
9032 | War and Peace: A Novel (6 Volumes) | Tolstoy Leo
10076
;
10177

10278

@@ -107,16 +83,15 @@ required_capability: match_operator_colon
10783
FROM books
10884
| WHERE title:"war and peace" AND author:"Tolstoy"
10985
| RERANK "war and peace" ON title WITH test_reranker
110-
| KEEP book_no, title, author, _score
86+
| KEEP book_no, title, author
11187
| SORT author, title
11288
| LIMIT 3
113-
| EVAL _score = ROUND(_score, 5)
11489
;
11590

116-
book_no:keyword | title:text | author:text | _score:double
117-
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy] | 0.02222
118-
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy | 0.01515
119-
5327 | War and Peace | Leo Tolstoy | 0.03846
91+
book_no:keyword | title:text | author:text
92+
4536 | War and Peace (Signet Classics) | [John Hockenberry, Leo Tolstoy, Pat Conroy]
93+
2776 | The Devil and Other Stories (Oxford World's Classics) | Leo Tolstoy
94+
5327 | War and Peace | Leo Tolstoy
12095
;
12196

12297

@@ -132,11 +107,10 @@ FROM books METADATA _id, _index, _score
132107
| RRF
133108
| RERANK "Tolkien" ON title WITH test_reranker
134109
| LIMIT 2
135-
| KEEP book_no, title, author, _score
136-
| EVAL _score = ROUND(_score, 5)
110+
| KEEP book_no, title, author
137111
;
138112

139-
book_no:keyword | title:keyword | author:keyword | _score:double
140-
5335 | Letters of J R R Tolkien | J.R.R. Tolkien | 0.02632
141-
2130 | The J. R. R. Tolkien Audio Collection | [Christopher Tolkien, John Ronald Reuel Tolkien] | 0.01961
113+
book_no:keyword | title:keyword | author:keyword
114+
5335 | Letters of J R R Tolkien | J.R.R. Tolkien
115+
2130 | The J. R. R. Tolkien Audio Collection | [Christopher Tolkien, John Ronald Reuel Tolkien]
142116
;

0 commit comments

Comments
 (0)