Allow empty json object in request body in `_count` API

When the request body is missing, all documents in the target index are counted.
As mentioned in #19422, the same should happen when the request body is an empty
json object. This is also the behaviour for the `_search` endpoint and the two
APIs should behave in the same way.
This commit is contained in:
Christoph Büscher 2016-07-25 20:00:35 +02:00
parent c7c0faa54d
commit b861ec1cc0
2 changed files with 18 additions and 3 deletions

View File

@ -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;

View File

@ -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: