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:
parent
c7c0faa54d
commit
b861ec1cc0
|
@ -73,9 +73,6 @@ public class QueryParseContext implements ParseFieldMatcherSupplier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (queryBuilder == null) {
|
|
||||||
throw new ParsingException(parser.getTokenLocation(), "Required query is missing");
|
|
||||||
}
|
|
||||||
return queryBuilder;
|
return queryBuilder;
|
||||||
} catch (ParsingException e) {
|
} catch (ParsingException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -37,6 +37,24 @@ setup:
|
||||||
|
|
||||||
- match: {count : 0}
|
- 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":
|
"count body without query element":
|
||||||
- do:
|
- do:
|
||||||
|
|
Loading…
Reference in New Issue