MongoDB DEV · Question 194 · Single choice

Aggregation: Question 5 Which of the following Aggregation queries will only return documents where "a" is greater than 5? Choose the best answer:

Answer options

  1. A.
    { limit: 5 }
  2. B.
    { $match: { a: { $gt: 5 } } }
  3. C.
    { $project: { a: 1 } }
  4. D.
    { $count: "a" }
  5. E.
    { $sort: { a: -1 } }

Answer confidence: High

Correct answer: B

Explanation language: Chinese

要只返回 a > 5 的文档只能用 $match 过滤。$limit 只限制条数、$project 只管字段、$sort 只排序、$count 只统计数量,都不过滤文档。

Papers containing this question

This question appears in 3 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 ↗