Skip to content

Commit 7b8176c

Browse files
committed
Wildcard term query has incorrect assertion
Wildcard term query currently has an assertion which fails if query contains a unicode character with surrogates. Despite the assertion, the query itself appears to work when assertions are disabled. Remove termQueries for now until this is fixed.
1 parent e25b09c commit 7b8176c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

test/framework/src/main/java/org/elasticsearch/datageneration/queries/LeafQueryGenerator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public List<QueryBuilder> generate(Map<String, Object> fieldMapping, String path
6262
if (s.isEmpty() || ignoreAbove < s.length()) {
6363
return List.of();
6464
}
65-
return List.of(QueryBuilders.termQuery(path, value), QueryBuilders.wildcardQuery(path, value + "*"));
65+
return List.of(QueryBuilders.wildcardQuery(path, value + "*"));
6666
}
6767
}
6868

@@ -73,16 +73,15 @@ public List<QueryBuilder> generate(Map<String, Object> fieldMapping, String path
7373
}
7474
var results = new ArrayList<QueryBuilder>();
7575
results.add(QueryBuilders.matchQuery(path, value));
76-
var phraseQuery = buildPhraseQuery(path, value);
76+
var phraseQuery = buildPhraseQuery(path, (String) value);
7777
if (phraseQuery != null) {
7878
results.add(phraseQuery);
7979
}
8080
return results;
8181
}
8282

83-
private static QueryBuilder buildPhraseQuery(String path, Object value) {
84-
String needle = (String) value;
85-
var tokens = Arrays.asList(needle.split("[^a-zA-Z0-9]"));
83+
private static QueryBuilder buildPhraseQuery(String path, String value) {
84+
var tokens = Arrays.asList(value.split("[^a-zA-Z0-9]"));
8685
if (tokens.isEmpty()) {
8786
return null;
8887
}

0 commit comments

Comments
 (0)