From d5316b2783b68305b342565fec531cd15e5772c1 Mon Sep 17 00:00:00 2001 From: javanna Date: Mon, 8 Aug 2016 19:42:01 +0200 Subject: [PATCH] Throw parsing error if match phrase query contains multiple fields in its short version --- .../index/query/MatchPhraseQueryBuilder.java | 4 ++++ .../index/query/MatchPhraseQueryBuilderTests.java | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java index c9667c98778..9f081d95ec2 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchPhraseQueryBuilder.java @@ -207,6 +207,10 @@ public class MatchPhraseQueryBuilder extends AbstractQueryBuilder parseQuery(json)); assertEquals("[match_phrase] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage()); + + String shortJson = "{\n" + + " \"match_phrase\" : {\n" + + " \"message1\" : \"this is a test\",\n" + + " \"message2\" : \"this is a test\"\n" + + " }\n" + + "}"; + e = expectThrows(ParsingException.class, () -> parseQuery(shortJson)); + assertEquals("[match_phrase] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage()); } }