From 7894eba2b3fd17bd035b91ec02c1205ef738d6e0 Mon Sep 17 00:00:00 2001 From: javanna Date: Tue, 13 Sep 2016 12:46:11 +0200 Subject: [PATCH] [TEST] add test for match query parsing error when providing an array of terms Match query throws parsing errors when an array of terms is provided, we should test that to make sure this behaviour doesn't change. Relates to #15741 --- .../index/query/MatchQueryBuilderTests.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java index ea6fa65dddb..9cc19928eb1 100644 --- a/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/MatchQueryBuilderTests.java @@ -431,4 +431,22 @@ public class MatchQueryBuilderTests extends AbstractQueryTestCase parseQuery(shortJson)); assertEquals("[match] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage()); } + + public void testParseFailsWithTermsArray() throws Exception { + String json1 = "{\n" + + " \"match\" : {\n" + + " \"message1\" : {\n" + + " \"query\" : [\"term1\", \"term2\"]\n" + + " }\n" + + " }\n" + + "}"; + expectThrows(ParsingException.class, () -> parseQuery(json1)); + + String json2 = "{\n" + + " \"match\" : {\n" + + " \"message1\" : [\"term1\", \"term2\"]\n" + + " }\n" + + "}"; + expectThrows(IllegalStateException.class, () -> parseQuery(json2)); + } }