MongoDB DBA · 题目 4 · 多选

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:

题目选项

  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} } }

答案置信度:高

正确答案:D、E

解析语言:中文

_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 是关键:点号路径既能穿数组也能穿嵌套对象。

所在套题

此题在题库中有 3 条记录。公开详情合并相同题干和选项;完整公开题展示置信度最高的一条记录,其他题目仅展示摘要。按套学习保留每条记录原有的答案、解析和置信度。

作者 · 作品 · 开源

作者与 MongoDB 作品

专注数据平台、MongoDB 迁移同步与云运维产品研发。

有任何 MongoDB 需求,均可联系作者。

联系作者 ↗mlhp123@outlook.com

支持作者

如果题库对您有帮助,欢迎自愿扫码打赏。

支付宝扫码打赏作者打开打赏原图 ↗