gpt4 book ai didi

graph - 类型错误 : Object # has no method 'indexOf'

转载 作者:行者123 更新时间:2023-12-05 01:04:15 25 4
gpt4 key购买 nike

我正在尝试对来自 this answer 的查询进行变体.我希望对顶点做一些进一步的过滤,以便我可以自定义前十名(使其成为给定年份或类似角色最多的前十名 Actor )。

如果我尝试使用 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 不同),我认为问题可能是这样,所以我尝试使用 path: 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

有人可以解释为什么我会收到此错误吗?

最佳答案

我认为问题在于上面查询中的 vert 是一个顶点对象,但预计它是一个顶点 _id(或顶点 _key)。这就是发生异常的原因。

第一个查询可以修改如下:

db._createStatement({query: 'FOR vert IN imdb_vertices FILTER vert.type == "Person" LET edge_count = (LENGTH(NEIGHBORS(imdb_vertices, imdb_edges, vert._id, "outbound", [{"type": "Role", "$label": "ACTS_IN"}]))) SORT edge_count DESC LIMIT 10 RETURN {"name": vert.name,  "count": edge_count}'}).execute().toArray()

关于graph - 类型错误 : Object #<ShapedJson> has no method 'indexOf' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23479788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com