我正在尝试对此答案的查询进行变体。我希望对顶点进行进一步过滤,以便我可以自定义前十名(使其成为给定年份或类似情况下角色最多的前十名演员)。
如果我尝试使用 NEIGHBORS 函数,则会收到以下错误:
arangosh [_system]> db._createStatement({query: 'FOR vert IN imdb_vertices FILTER vert.type == "Person" LET edge_count = (LENGTH(NEIGHBORS(imdb_vertices, imdb_edges, vert, "outbound", [{"type": "Role", "$label": "ACTS_IN"}]))) SORT edge_count DESC LIMIT 10 RETURN {"name": vert.name, "count": edge_count}'}).execute().toArray()
JavaScript exception in file '/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js' at 101,13: TypeError: TypeError: Object #<ShapedJson> has no method 'indexOf'
! throw new TypeError(requestResult.errorMessage);
! ^
stacktrace: TypeError: TypeError: Object #<ShapedJson> has no method 'indexOf'
at Object.exports.checkRequestResult (/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js:101:13)
at ArangoStatement.execute (/usr/share/arangodb/js/client/modules/org/arangodb/arango-statement.js:171:12)
at (shell):1:290
由于 NEIGHBORS 似乎同时返回边和顶点(与返回边的 EDGES 不同),我认为问题可能是这样,所以我尝试使用 paths: false 选项使用 TRAVERSAL。不幸的是,它给出了同样的错误:
db._createStatement({query: 'FOR vert IN imdb_vertices FILTER vert.type == "Person" LET edge_count = (LENGTH(TRAVERSAL(imdb_vertices,imdb_edges, vert, "outbound", {paths: false, followEdges: [{"type": "Role", "$label": "ACTS_IN"}]}))) SORT edge_count DESC LIMIT 10 RETURN {"name": vert.name, "count": edge_count}'}).execute().toArray()
JavaScript exception in file '/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js' at 101,13: TypeError: TypeError: Object #<ShapedJson> has no method 'indexOf'
! throw new TypeError(requestResult.errorMessage);
! ^
stacktrace: TypeError: TypeError: Object #<ShapedJson> has no method 'indexOf'
at Object.exports.checkRequestResult (/usr/share/arangodb/js/client/modules/org/arangodb/arangosh.js:101:13)
at ArangoStatement.execute (/usr/share/arangodb/js/client/modules/org/arangodb/arango-statement.js:171:12)
at (shell):1:318
有人可以解释为什么我会收到此错误吗?