Throw parsing error if match query contains multiple fields in its short version
This commit is contained in:
parent
d5316b2783
commit
040f9c6be6
|
@ -603,6 +603,10 @@ public class MatchQueryBuilder extends AbstractQueryBuilder<MatchQueryBuilder> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (fieldName != null) {
|
||||
throw new ParsingException(parser.getTokenLocation(), "[match] query doesn't support multiple fields, found ["
|
||||
+ fieldName + "] and [" + parser.currentName() + "]");
|
||||
}
|
||||
fieldName = parser.currentName();
|
||||
value = parser.objectText();
|
||||
}
|
||||
|
|
|
@ -421,5 +421,14 @@ public class MatchQueryBuilderTests extends AbstractQueryTestCase<MatchQueryBuil
|
|||
"}";
|
||||
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
|
||||
assertEquals("[match] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
|
||||
|
||||
String shortJson = "{\n" +
|
||||
" \"match\" : {\n" +
|
||||
" \"message1\" : \"this is a test\",\n" +
|
||||
" \"message2\" : \"this is a test\"\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
|
||||
assertEquals("[match] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue