ArangoDB 3.0 中朋友的朋友查询 [英] friends of friend Query in ArangoDB 3.0

查看:29
本文介绍了ArangoDB 3.0 中朋友的朋友查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想使用 AQL

我有一个名称为:User 的集合和一个名称为 Conatct 的边缘集合.

I have a Collection with Name:User and a edge Collection with name Conatct.

我的联系方式文档:


我还阅读了这篇文章在 ArangoDb 中实现朋友的朋友,但那是使用 GRAPH_NEIGHBORS() 函数的低版本 ArangoDB 的函数.


I also read this article that implement friends of friend in ArangoDb, but that's post Uses functions of lower version of ArangoDB that used GRAPH_NEIGHBORS() function.

在 ArnagoDB 3.0(最新版本)中,GRAPH_NEIGHBORS() 函数已被删除!

in ArnagoDB 3.0(latest version), GRAPH_NEIGHBORS() function have been removed!

现在,如何在 ArnagoDB 3.0 中使用 Aql 实现 fof ?

now, how can I implement fof using Aql in ArnagoDB 3.0 ?

非常感谢

推荐答案

图函数已被移除,因为有更强大、更灵活和更高效的原生 AQL 遍历,在 2.8 中引入,并针对 3.0 版本进行了扩展和优化.

The graph functions have been removed, because there is the more powerful, flexible and performant native AQL traversal, which was introduced with 2.8, and extended and optimized for version 3.0.

要检索朋友的朋友,需要从有问题的用户开始遍历,遍历深度 = 2:

To retrieve friends of friends, a traversal starting at the user in question with a traversal depth = 2 is needed:

LET user = DOCUMENT("User/@9302796301")
LET foaf = (
  FOR v IN 2..2 ANY user Contact
    RETURN v // you might wanna return the name only here
)
RETURN MERGE(user, { foaf } )

_key = @9302796301 用户的文档被加载并分配给变量 user.它用作最小和最大深度 = 2 的遍历的起始顶点,使用集合 Contact 的边缘并忽略它们的方向(ANY;也可以是 INBOUNDOUTBOUND).本例中朋友文档完全返回(v)并与user文档合并,使用属性键"foaf"和变量 foaf 的值.

The document for the user with _key = @9302796301 is loaded and assigned to a variable user. It is used as start vertex for a traversal with min and max depth = 2, using the edges of the collection Contact and ignoring their direction (ANY; can also be INBOUND or OUTBOUND). The friends of friends documents are fully returned in this example (v) and merged with the user document, using the attribute key "foaf" and the value of the variable foaf.

这只是如何遍历图和如何构造结果集的一个简单示例.当然还有更多选择.

This is just one simple example how to traverse graphs and how to construct result sets. There are many more options of course.

这篇关于ArangoDB 3.0 中朋友的朋友查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆