MongoDB DBA · Question 4 · Multiple choice

4. Which documents will be returned by the following query? db.cars.find({ "miles": { "$lt": 300 }, "model.reviews.stars": { "$gte": 4 } }) Check all that apply:

Answer options

  1. A.
    { "_id": 671, "year": 1983, "miles": 2000, "model": { "name": "Fiesta", "reviews": [ { "user": "marjory", "comment": "loved it", "stars": 10 } ] } }
  2. B.
    { "_id": 971, "year": 2000, "miles": 300, "model": { "name": "Corolla", "reviews": [ { "user": "fred", "comment": "Great!", "stars": 5 }, { "user": "bill", "comment": "could be better", "stars": 3 } ] } }
  3. C.
    { "_id": 3441, "year": 2007, "miles": 256, "model": { "name": "Continental", "reviews": [ { "user": "bridgett", "comment": "average", "stars": 3 }, { "user": "andreas", "comment": "Really liked the color of the leather", "stars": 3 } { "user": "manafort", "comment": "not russian enough", "stars": 2 } ] } }
  4. D.
    { "_id": 21, "year": 2017, "miles": 200, "model": { "reviews": [ { "user": "fred", "comment": "Great!", "stars": 5 }, { "user": "bill", "comment": "could be better", "stars": 3 } ] } }
  5. E.
    { "_id": 3, "year": 2001, "miles": 278, "model": { "name": "627", "reviews": { "user": "brad", "comment": "very slick", "stars": 5} } }

Answer confidence: High

Correct answer: D, E

Explanation language: Chinese

_id 21(miles 200<300,reviews 数组里 stars 5≥4)与 _id 3(miles 278<300,model.reviews 是单个对象而非数组,点号路径照样能取到 stars 5)都命中。_id 671 的 miles 2000 超限;_id 971 的 miles 正好等于 300,不满足 $lt 300;_id 3441 的 stars 全为 2/3。E 是关键:点号路径既能穿数组也能穿嵌套对象。

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 ↗