如何在MongoDB 3.4.0中使用$ graphLookup创建视图?

时间:2016-11-21 04:01:32

标签: mongodb view aggregation-framework

我在管道中使用$graphLookup创建了一个视图,但失败了。有人有什么想法吗?

$cmd

{
  "create": "employee.view.list",
  "viewOn": "employee",
  "pipeline": [
    {
      "$graphLookup": {
        "from": "employee.view.list",
        "connectToField": "_id",
        "startWith": "$supervisor",
        "connectFromField": "supervisor",
        "as": "supervisors",
        "maxDepth": 10
      }
    }
  ]
}

错误

  

检测到查看周期:test_sw-aggregation-test.employee.view.list => test_sw聚集-test.employee.view.list

1 个答案:

答案 0 :(得分:1)

您收到此错误的原因是您创建的视图与要在其文档中执行employee.view.list的集合同名。

同样{ "ok" : 0, "errmsg" : "a view 'employee.view.list' already exists", "code" : 48, "codeName" : "NamespaceExists" } 不是预定义视图,在这种情况下,您将收到如下所示的错误消息:

yum install spark