Added tests for match/multimatch queries with invalid “type” JSON param

This commit is contained in:
markharwood 2014-02-03 11:39:23 +00:00
parent 88771fdf99
commit 82c7c81653
3 changed files with 41 additions and 0 deletions

View File

@ -2210,6 +2210,19 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
Query parsedQuery = queryParser.parse(query).query();
assertThat((double) (parsedQuery.getBoost()), Matchers.closeTo(3.0, 1.e-7));
}
@Test
public void testBadTypeMatchQuery() throws Exception {
IndexQueryParserService queryParser = queryParser();
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/match-query-bad-type.json");
QueryParsingException expectedException = null;
try {
queryParser.parse(query).query();
} catch (QueryParsingException qpe) {
expectedException = qpe;
}
assertThat(expectedException, notNullValue());
}
@Test
public void testMultiMatchQuery() throws Exception {
@ -2219,6 +2232,19 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class));
}
@Test
public void testBadTypeMultiMatchQuery() throws Exception {
IndexQueryParserService queryParser = queryParser();
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/multiMatch-query-bad-type.json");
QueryParsingException expectedException = null;
try {
queryParser.parse(query).query();
} catch (QueryParsingException qpe) {
expectedException = qpe;
}
assertThat(expectedException, notNullValue());
}
@Test
public void testMultiMatchQueryWithFieldsAsString() throws Exception {
IndexQueryParserService queryParser = queryParser();

View File

@ -0,0 +1,8 @@
{
"match" : {
"message" : {
"query" : "this is a test",
"type" : "doesNotExist"
}
}
}

View File

@ -0,0 +1,7 @@
{
"multi_match": {
"query": "foo bar",
"fields": [ "myField", "otherField" ],
"type":"doesNotExist"
}
}