MongoDB 3.4.8无法识别的管道阶段名称:'$ lookup'

时间:2017-09-09 06:55:58

标签: mongodb

我正在使用MongoDB版本3.4.8并执行聚合以从两个集合中获取数据但我收到此错误 -

Assert: command failed: {
"errmsg" : "exception: Unrecognized pipeline stage name: '$lookup'",
"code" : 16436,
"ok" : 0
} : aggregate failed

我的收藏品是 -

favourite_cameras is {
"_id" : ObjectId("59b3846adacd8a1afd8696a1"),
"Member_ID" : 712,
"MemberToken" : "Ns9fAEHYRkVgAZJb4UD3gbLWWIJiEoYn",
"Favourite_Camera_ID" : "1003",
"lastUpdated" : "2017-09-09 11:34:26"
}

traffic_images - {
"_id" : ObjectId("59b36caf32586b76d2a68160"),
"CameraID" : "1003",
"CameraName" : "ACE",
"lastUpdated" : "2017-09-09 09:53:11"
}

我的查询是 -

db.favourite_cameras.aggregate([{
  $lookup:
    {
      from: "traffic_images",
      localField: "Favourite_Camera_ID",
      foreignField: "CameraID",
      as: "favs"
    }
}])

1 个答案:

答案 0 :(得分:1)

升级Mongo Shell版本后,您还必须设置功能兼容性。

升级功能兼容性:

use admin;
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } );

希望它有所帮助。