diff --git a/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java b/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java index 510a8049630..33382a7ab73 100644 --- a/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java +++ b/core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java @@ -73,9 +73,6 @@ public class QueryParseContext implements ParseFieldMatcherSupplier { } } } - if (queryBuilder == null) { - throw new ParsingException(parser.getTokenLocation(), "Required query is missing"); - } return queryBuilder; } catch (ParsingException e) { throw e; diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/count/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/count/10_basic.yaml index f3eb0a5fae6..f38d2c315eb 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/count/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/count/10_basic.yaml @@ -37,6 +37,24 @@ setup: - match: {count : 0} +--- +"count with empty body": +# empty body should default to match_all query + - do: + count: + index: test + type: test + body: { } + + - match: {count : 1} + + - do: + count: + index: test + type: test + + - match: {count : 1} + --- "count body without query element": - do: