[英]How to use UNION_DISTINCT() or INTERSECTION() after deprecation of NEIGHBORS()
I am new to ArangoDB and am trying to reproduce the results of https://docs.arangodb.com/3.0/cookbook/Graph/ExampleActorsAndMovies.html It turns out that functions like NEIGHBORS() are deprecated in 3.0. 我是ArangoDB的新手,正在尝试重现https://docs.arangodb.com/3.0/cookbook/Graph/ExampleActorsAndMovies.html的结果。事实证明,像NEIGHBORS()这样的函数已在3.0中弃用。 There is a migration guide https://docs.arangodb.com/3.0/cookbook/AQL/MigratingEdgeFunctionsTo3.html with which I manage to get
有一个迁移指南https://docs.arangodb.com/3.0/cookbook/AQL/MigratingEdgeFunctionsTo3.html ,我可以从中获取
db._query("RETURN NEIGHBORS(movies, actsIn, 'TheMatrix', 'any')").toArray();
to work again as 再次作为
db._query("FOR x IN ANY 'movies/TheMatrix' actsIn RETURN x._key").toArray();
However, I am at a loss how to use UNION_DISTINCT
or INTERSECTION
as the RETURN
statement sits inside the loop, not outside. 但是,由于
RETURN
语句位于循环内部而不是外部,我不知如何使用UNION_DISTINCT
或INTERSECTION
。 Also, I cannot seem to find any documentation on given functions anywhere? 另外,我似乎无法在任何地方找到有关给定功能的任何文档?
For instance: "All actors who acted in both "movie1" AND "movie2" ?" 例如:“所有在“ movie1”和“ movie2”中都扮演过的演员?” would have been queried as
将被查询为
db._query("RETURN INTERSECTION(NEIGHBORS(movies, actsIn, 'TheDevilsAdvocate', 'any'), NEIGHBORS(movies, actsIn, 'TheMatrix', 'any'))").toArray();
which reads naturally coming from an sql background. 它读取自然是来自sql背景。 But how would one go about this using above-mentioned for loop?
但是如何使用上述的for循环来进行呢?
Any help would be much appreciated. 任何帮助将非常感激。
You can find the documentation for these functions here: https://docs.arangodb.com/3.0/AQL/Functions/Array.html 您可以在以下位置找到这些功能的文档: https : //docs.arangodb.com/3.0/AQL/Functions/Array.html
Your AQL for the cookbook-example should look like these: 您的食谱示例的AQL应该如下所示:
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.