Skip to content

Commit e7c23b1

Browse files
Fix flaky ExistsQueryBuilderTests.testToQuery (#18995) (#19027)
--------- (cherry picked from commit 86ac3ab) Signed-off-by: Atri Sharma <atri.jiit@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 3fa4dfd commit e7c23b1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/test/java/org/opensearch/index/query/ExistsQueryBuilderTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,20 @@ protected ExistsQueryBuilder doCreateTestQueryBuilder() {
6060
} else {
6161
fieldPattern = randomAlphaOfLengthBetween(1, 10);
6262
}
63+
64+
// Avoid patterns that would match the derived field "raw.derived_keyword"
65+
// which doesn't support exists queries
66+
if (fieldPattern.startsWith("raw")) {
67+
fieldPattern = TEXT_FIELD_NAME;
68+
}
69+
6370
// also sometimes test wildcard patterns
6471
if (randomBoolean()) {
65-
if (randomBoolean()) {
72+
if (randomBoolean() && !fieldPattern.equals("r") && !fieldPattern.equals("ra")) {
6673
fieldPattern = fieldPattern + "*";
6774
}
6875
}
76+
6977
return new ExistsQueryBuilder(fieldPattern);
7078
}
7179

0 commit comments

Comments
 (0)