match_all filter with empty array (instead of obj) fires exception when used with facets
fixes #2493
This commit is contained in:
parent
2a57e7cd4b
commit
8a17222ff2
|
@ -48,7 +48,7 @@ public class MatchAllFilterParser implements FilterParser {
|
|||
XContentParser parser = parseContext.parser();
|
||||
|
||||
XContentParser.Token token;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
while (((token = parser.nextToken()) != XContentParser.Token.END_OBJECT && token != XContentParser.Token.END_ARRAY)) {
|
||||
}
|
||||
|
||||
return Queries.MATCH_ALL_FILTER;
|
||||
|
|
|
@ -53,7 +53,7 @@ public class MatchAllQueryParser implements QueryParser {
|
|||
String currentFieldName = null;
|
||||
|
||||
XContentParser.Token token;
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
while (((token = parser.nextToken()) != XContentParser.Token.END_OBJECT && token != XContentParser.Token.END_ARRAY)) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token.isValue()) {
|
||||
|
|
|
@ -259,6 +259,22 @@ public class SimpleIndexQueryParserTests {
|
|||
assertThat((double) matchAllDocsQuery.getBoost(), closeTo(1.2, 0.01));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAllEmpty1() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/match_all_empty1.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, sameInstance(Queries.MATCH_ALL_QUERY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchAllEmpty2() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/query/match_all_empty2.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, sameInstance(Queries.MATCH_ALL_QUERY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStarColonStar() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"match_all": {}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"match_all": []
|
||||
}
|
Loading…
Reference in New Issue