Consider the following query: db.movies.find( {"countries.0": "France", "genres.0": "Documentary"}, {"countries":1, "genres":1, "title":1, "year":1, "_id":0} ) Which of the following documents could be returned by this query: Choose the best answer:
题目选项
- A.{ "genres" : [ "Documentary" ], "title" : "F for Fake", "year" : 1973, "countries" : [ "France", "Iran", "West Germany" ] }
- B.{ "_id" : ObjectId("573a1399f29313caabcedc24"), "genres" : [ "Documentary" ], "title" : "It's All True", "year" : 1993, "countries" : [ "France", "USA" ] }
- C.{ "genres" : [ "Documentary" ], "title" : "Nanook of the North", "year" : 1922, "countries" : [ "USA", "France" ] }
- D.{ "genres" : [ "Documentary", "History", "Music" ], "title" : "Woodstock", "year" : 1970, "countries" : [ "USA" ] }
答案置信度:高
正确答案:A
解析语言:中文
"countries.0"/"genres.0" 是按数组下标做的等值匹配:要求 countries 的第一个元素是 France、genres 的第一个元素是 Documentary。投影里写了 _id:0,因此返回文档不能含 _id,只有 A 同时满足(B 带 _id 与投影矛盾,C 的 countries[0] 是 USA,D 的 countries 只有 USA)。