如何在弃用 NEIGHBORS() 后使用 UNION_DISTINCT() 或 INTERSECTION()

How to use UNION_DISTINCT() or INTERSECTION() after deprecation of NEIGHBORS()

我是 ArangoDB 的新手,我正在尝试重现我设法获得

https://docs.arangodb.com/3.0/cookbook/Graph/ExampleActorsAndMovies.html It turns out that functions like NEIGHBORS() are deprecated in 3.0. There is a migration guide https://docs.arangodb.com/3.0/cookbook/AQL/MigratingEdgeFunctionsTo3.html 结果
db._query("RETURN NEIGHBORS(movies, actsIn, 'TheMatrix', 'any')").toArray();

再次工作

db._query("FOR x IN ANY 'movies/TheMatrix' actsIn RETURN x._key").toArray();

但是,我不知道如何使用 UNION_DISTINCTINTERSECTION,因为 RETURN 语句位于循环内部,而不是外部。另外,我似乎无法在任何地方找到有关给定功能的任何文档?

例如:"All actors who acted in both "movie1" AND "movie2" ?"会被查询为

db._query("RETURN INTERSECTION(NEIGHBORS(movies, actsIn, 'TheDevilsAdvocate', 'any'), NEIGHBORS(movies, actsIn, 'TheMatrix', 'any'))").toArray();

自然地从 sql 背景读取。但是如何使用上述 for 循环来解决这个问题?

如有任何帮助,我们将不胜感激。

您可以在此处找到这些函数的文档:https://docs.arangodb.com/3.0/AQL/Functions/Array.html

食谱示例的 AQL 应如下所示:

UNION_DISTINCT

db._query("FOR x IN UNION_DISTINCT ((FOR y IN ANY 'movies/TheMatrix' actsIn RETURN y), (FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn RETURN y)) RETURN x._id").toArray()

交叉点

db._query("FOR x IN INTERSECTION ((FOR y IN ANY 'movies/TheMatrix' actsIn RETURN y), (FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn RETURN y)) RETURN x._id").toArray()