Skip to content

Commit 5a2d69b

Browse files
committed
Fix PushQueriesIT for new query rewrite optimizations in Lucene 10.3
1 parent 703e2f5 commit 5a2d69b

File tree

1 file changed

+8
-6
lines changed
  • x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node

1 file changed

+8
-6
lines changed

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/PushQueriesIT.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ public void testEqualityOrOther() throws IOException {
146146
FROM test
147147
| WHERE test == "%value" OR foo == 2
148148
""";
149+
// query rewrite optimizations apply to foo, since it's query value is always outside the range of indexed values
149150
String luceneQuery = switch (type) {
150-
case AUTO, TEXT_WITH_KEYWORD -> "(#test.keyword:%value -_ignored:test.keyword) foo:[2 TO 2]";
151-
case KEYWORD -> "test:%value foo:[2 TO 2]";
151+
case AUTO, TEXT_WITH_KEYWORD -> "#test.keyword:%value -_ignored:test.keyword";
152+
case KEYWORD -> "test:%value";
152153
case CONSTANT_KEYWORD, MATCH_ONLY_TEXT_WITH_KEYWORD -> "*:*";
153154
case SEMANTIC_TEXT_WITH_KEYWORD -> "FieldExistsQuery [field=_primary_term]";
154155
};
@@ -165,16 +166,17 @@ public void testEqualityAndOther() throws IOException {
165166
FROM test
166167
| WHERE test == "%value" AND foo == 1
167168
""";
169+
// query rewrite optimizations apply to foo, since it's query value is always within the range of indexed values
168170
List<String> luceneQueryOptions = switch (type) {
169-
case AUTO, TEXT_WITH_KEYWORD -> List.of("#test.keyword:%value -_ignored:test.keyword #foo:[1 TO 1]");
170-
case KEYWORD -> List.of("#test:%value #foo:[1 TO 1]");
171-
case CONSTANT_KEYWORD, MATCH_ONLY_TEXT_WITH_KEYWORD -> List.of("foo:[1 TO 1]");
171+
case AUTO, TEXT_WITH_KEYWORD -> List.of("#test.keyword:%value -_ignored:test.keyword");
172+
case KEYWORD -> List.of("test:%value");
173+
case CONSTANT_KEYWORD, MATCH_ONLY_TEXT_WITH_KEYWORD -> List.of("*:*");
172174
case SEMANTIC_TEXT_WITH_KEYWORD ->
173175
/*
174176
* single_value_match is here because there are extra documents hiding in the index
175177
* that don't have the `foo` field.
176178
*/
177-
List.of("#foo:[1 TO 1] #single_value_match(foo)", "foo:[1 TO 1]");
179+
List.of("#FieldExistsQuery [field=foo] #single_value_match(foo)", "foo:[1 TO 1]");
178180
};
179181
ComputeSignature dataNodeSignature = switch (type) {
180182
case AUTO, CONSTANT_KEYWORD, KEYWORD, TEXT_WITH_KEYWORD -> ComputeSignature.FILTER_IN_QUERY;

0 commit comments

Comments
 (0)