-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.4.4
-
Component/s: Aggregation Framework
-
None
-
Query Optimization
-
ALL
-
Hi,
During an aggregation, we need to count the number of elements matching a specific rule. It works properly most of the time, however when there is no matching document (or the collection itself is empty), we get an empty result instead of a document with count equal to 0.
We understand this is probably a optimization to avoid processing stages on empty result, however operation such as count should probably be computed anyway in order to produce a consistent result.
The reason why we want to apply count inside aggregation instead of the aggregation result is because we would like to apply MongoDB expression evaluation on it (i.e. {count: { $eq: 20 }} for example).
- is related to
-
SERVER-80458 $count aggregation stage does return nothing when count is zero
- Backlog
-
SERVER-3241 Why does group return an empty result when no documents are matched?
- Closed