MongoDB DBA · Question 543 · Multiple choice

3. Which of the following is true about the $group Aggregation Framework stage? Check all that apply:

Answer options

  1. A.
    If null is pasted to _id parameter in the $group stage then all documents will be placed in a single new group.
  2. B.
    The $group stage can only be used once in an Aggregation pipeline.
  3. C.
    Accumulator expressions can be used in the $group stage.
  4. D.
    The _id parameter in the $group stage is how incoming documents are grouped in this stage.

Answer confidence: High

Correct answer: A, C, D

Explanation language: Chinese

$group 的 _id 就是分组键,_id 为 null 时所有输入文档进入同一个组(A、D 正确);累加器表达式($sum、$avg、$push 等)只能出现在 $group 阶段(C 正确)。B 错:一个聚合管道里可以多次使用 $group(例如先按天分组再按月分组)。

Papers containing this question

This question appears in 1 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗