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