Throw parsing error if wildcard query contains multiple fields in its short version
This commit is contained in:
parent
796bc74163
commit
27a6983646
|
@ -174,6 +174,10 @@ public class WildcardQueryBuilder extends AbstractQueryBuilder<WildcardQueryBuil
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (fieldName != null) {
|
||||
throw new ParsingException(parser.getTokenLocation(), "[wildcard] query doesn't support multiple fields, found ["
|
||||
+ fieldName + "] and [" + parser.currentName() + "]");
|
||||
}
|
||||
fieldName = parser.currentName();
|
||||
value = parser.text();
|
||||
}
|
||||
|
|
|
@ -113,5 +113,15 @@ public class WildcardQueryBuilderTests extends AbstractQueryTestCase<WildcardQue
|
|||
"}";
|
||||
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
|
||||
assertEquals("[wildcard] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
|
||||
|
||||
String shortJson =
|
||||
"{\n" +
|
||||
" \"wildcard\": {\n" +
|
||||
" \"user1\": \"ki*y\",\n" +
|
||||
" \"user2\": \"ki*y\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
|
||||
assertEquals("[wildcard] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue