Skip to content

Commit b3e9a64

Browse files
committed
Fix tests
1 parent 1056909 commit b3e9a64

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/MatchFunctionIT.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void testWhereMatchWithScoringNoSort() {
168168
var query = """
169169
FROM test
170170
METADATA _score
171-
| WHERE content:"fox"
171+
| WHERE match(content, "fox")
172172
| KEEP id, _score
173173
""";
174174

@@ -182,7 +182,7 @@ public void testWhereMatchWithScoringNoSort() {
182182
public void testNonExistingColumn() {
183183
var query = """
184184
FROM test
185-
| WHERE something:"fox"
185+
| WHERE match(something, "fox")
186186
""";
187187

188188
var error = expectThrows(VerificationException.class, () -> run(query));
@@ -193,14 +193,14 @@ public void testWhereMatchEvalColumn() {
193193
var query = """
194194
FROM test
195195
| EVAL upper_content = to_upper(content)
196-
| WHERE upper_content:"FOX"
196+
| WHERE match(upper_content, "FOX")
197197
| KEEP id
198198
""";
199199

200200
var error = expectThrows(VerificationException.class, () -> run(query));
201201
assertThat(
202202
error.getMessage(),
203-
containsString("[:] operator cannot operate on [upper_content], which is not a field from an index mapping")
203+
containsString("[MATCH] function cannot operate on [upper_content], which is not a field from an index mapping")
204204
);
205205
}
206206

@@ -209,21 +209,21 @@ public void testWhereMatchOverWrittenColumn() {
209209
FROM test
210210
| DROP content
211211
| EVAL content = CONCAT("document with ID ", to_str(id))
212-
| WHERE content:"document"
212+
| WHERE match(content, "document")
213213
""";
214214

215215
var error = expectThrows(VerificationException.class, () -> run(query));
216216
assertThat(
217217
error.getMessage(),
218-
containsString("[:] operator cannot operate on [content], which is not a field from an index mapping")
218+
containsString("[MATCH] function cannot operate on [content], which is not a field from an index mapping")
219219
);
220220
}
221221

222222
public void testWhereMatchAfterStats() {
223223
var query = """
224224
FROM test
225225
| STATS count(*)
226-
| WHERE content:"fox"
226+
| WHERE match(content, "fox")
227227
""";
228228

229229
var error = expectThrows(VerificationException.class, () -> run(query));
@@ -233,39 +233,39 @@ public void testWhereMatchAfterStats() {
233233
public void testWhereMatchWithFunctions() {
234234
var query = """
235235
FROM test
236-
| WHERE content:"fox" OR to_upper(content) == "FOX"
236+
| WHERE match(content, "fox") OR to_upper(content) == "FOX"
237237
""";
238238
var error = expectThrows(ElasticsearchException.class, () -> run(query));
239239
assertThat(
240240
error.getMessage(),
241241
containsString(
242-
"Invalid condition [content:\"fox\" OR to_upper(content) == \"FOX\"]. "
243-
+ "[:] operator can be used in an OR condition, but only if just full text functions are used in the OR condition"
242+
"Invalid condition [match(content, \"fox\") OR to_upper(content) == \"FOX\"]. "
243+
+ "[MATCH] function can be used in an OR condition, but only if just full text functions are used in the OR condition"
244244
)
245245
);
246246
}
247247

248248
public void testWhereMatchWithRow() {
249249
var query = """
250250
ROW content = "a brown fox"
251-
| WHERE content:"fox"
251+
| WHERE match(content, "fox")
252252
""";
253253

254254
var error = expectThrows(ElasticsearchException.class, () -> run(query));
255255
assertThat(
256256
error.getMessage(),
257-
containsString("[:] operator cannot operate on [\"a brown fox\"], which is not a field from an index mapping")
257+
containsString("[MATCH] function cannot operate on [\"a brown fox\"], which is not a field from an index mapping")
258258
);
259259
}
260260

261261
public void testMatchWithinEval() {
262262
var query = """
263263
FROM test
264-
| EVAL matches_query = content:"fox"
264+
| EVAL matches_query = match(content, "fox")
265265
""";
266266

267267
var error = expectThrows(VerificationException.class, () -> run(query));
268-
assertThat(error.getMessage(), containsString("[:] operator is only supported in WHERE commands"));
268+
assertThat(error.getMessage(), containsString("[MATCH] function is only supported in WHERE commands"));
269269
}
270270

271271
private void createAndPopulateIndex() {

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/MatchOperatorIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ public void testWhereMatchWithFunctions() {
215215
assertThat(
216216
error.getMessage(),
217217
containsString(
218-
"Invalid condition [content:\"fox\" OR to_upper(content) == \"FOX\"]. " + "[:] operator can't be used in an OR condition"
218+
"Invalid condition [content:\"fox\" OR to_upper(content) == \"FOX\"]. "
219+
+ "[:] operator can be used in an OR condition, but only if just full text functions are used in the OR condition"
219220
)
220221
);
221222
}

0 commit comments

Comments
 (0)