Added tests for match/multimatch queries with invalid “type” JSON param
This commit is contained in:
parent
88771fdf99
commit
82c7c81653
|
@ -2211,6 +2211,19 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
|
|||
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 {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"match" : {
|
||||
"message" : {
|
||||
"query" : "this is a test",
|
||||
"type" : "doesNotExist"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"multi_match": {
|
||||
"query": "foo bar",
|
||||
"fields": [ "myField", "otherField" ],
|
||||
"type":"doesNotExist"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue