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

@ -2211,6 +2211,19 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
assertThat((double) (parsedQuery.getBoost()), Matchers.closeTo(3.0, 1.e-7)); 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 @Test
public void testMultiMatchQuery() throws Exception { public void testMultiMatchQuery() throws Exception {
IndexQueryParserService queryParser = queryParser(); IndexQueryParserService queryParser = queryParser();
@ -2219,6 +2232,19 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
assertThat(parsedQuery, instanceOf(DisjunctionMaxQuery.class)); 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 @Test
public void testMultiMatchQueryWithFieldsAsString() throws Exception { public void testMultiMatchQueryWithFieldsAsString() throws Exception {
IndexQueryParserService queryParser = queryParser(); 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"
}
}