Added tests for match/multimatch queries with invalid “type” JSON param
This commit is contained in:
parent
88771fdf99
commit
82c7c81653
|
@ -2210,6 +2210,19 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
|
||||||
Query parsedQuery = queryParser.parse(query).query();
|
Query parsedQuery = queryParser.parse(query).query();
|
||||||
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 {
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -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