MongoDB DBA · Question 5 · Multiple choice

5. Consider a collection called coll which contains only the following documents: { _id: 4, a: [ 3, 3, 7 ], b: 5 } { _id: 5, a: [ 6, 8, 7 ], b: 3 } { _id: 6, a: [ 4, 9, 4 ], b: 8 } Which of the following documents from the coll collection will be returned by this query? db.coll.find({ "a": { "$lte": 4 }, b: { "$ne": 5 }}) Check all that apply:

Answer options

  1. A.
    { _id: 4, a: [ 3, 3, 7 ], b: 5 }
  2. B.
    { _id: 5, a: [ 6, 8, 7 ], b: 3 }
  3. C.
    { _id: 6, a: [ 4, 9, 4 ], b: 8 }

Answer confidence: High

Correct answer: C

Explanation language: Chinese

数组字段的匹配规则是"任一元素满足即匹配":_id 4 的 a 含 3≤4,但 b=5 被 $ne 5 排除;_id 5 的 a=[6,8,7] 没有 ≤4 的元素;只有 _id 6(a 含 4、b=8)同时满足两个条件。不要误以为数组查询要求所有元素都满足条件。

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 ↗