Aggregation: Question 5 Which of the following Aggregation queries will only return documents where "a" is greater than 5? Choose the best answer:
题目选项
- A.{ limit: 5 }
- B.{ $match: { a: { $gt: 5 } } }
- C.{ $project: { a: 1 } }
- D.{ $count: "a" }
- E.{ $sort: { a: -1 } }
答案置信度:高
正确答案:B
解析语言:中文
要只返回 a > 5 的文档只能用 $match 过滤。$limit 只限制条数、$project 只管字段、$sort 只排序、$count 只统计数量,都不过滤文档。