Which of the following is true about the $group Aggregation Framework stage? Check all that apply:
题目选项
- A.If null is pasted to _id parameter in the $group stage then all documents will be placed in a single new group.
- B.The $group stage can only be used once in an Aggregation pipeline.
- C.Accumulator expressions can be used in the $group stage.
- D.The _id parameter in the $group stage is how incoming documents are grouped in this stage.
答案置信度:高
正确答案:A、C、D
解析语言:中文
$group 的 _id 就是分组键,_id 为 null 时所有输入文档进入同一个组(A、D 正确);累加器表达式($sum、$avg、$push 等)只能出现在 $group 阶段(C 正确)。B 错:一个聚合管道里可以多次使用 $group(例如先按天分组再按月分组)。