gremlin - 如何在图数据库中查询多个顶点和边
问题描述
我正在使用 DSE 图。我有一个这样的模型:
AccountGroup“由”帐户(AccountGroup -> Account)组成。配置文件“accesses_to”帐户(配置文件 -> 帐户)。
现在给定一个 account_id,我需要返回与该 Account 相关的所有顶点和边。
我的 gremlin 代码如下所示:
g.V().has('Account', 'account_id', '123456').in().hasLabel('AccountGroup')
这只会为 Account 返回一个 AccountGroup。如何编写获取所有 Account、AccountGroup 和 Profile 的查询?
解决方案
我认为您想要所有相关顶点的路径或只是一棵树。所以它是:
g.V().has('Account', 'account_id', '123456').
inE('consists of','accesses_to').outV().
path()
... 或这个:
g.V().has('Account', 'account_id', '123456').
inE('consists of','accesses_to').outV().
tree()
后者是一种更紧凑的格式,但在客户端可能更难处理。
推荐阅读
- php - 无法更新数据库中的数据
- python - 气流 execution_date 错误值
- sql-server - 使用名为“发送”的 BIT 字段更改 MS-SQL-Management Studio (SSMS) 中的数据失败
- python - 以编程方式检查并禁用 IPython 自动重载扩展
- parsing - 在不依赖词法分析器规范的情况下生成一个解析器生成器的小型工作示例?
- css - 是否可以使用多个选择器 CSS 为多个类描述相同的样式
- azure - Azure API 管理负载大小
- android - 如何使 setBackgroundResource 使用 SharedPreferences 保存图像
- javascript - 对于这个数据结构/算法问题,我应该如何改变我的方法?
- java - 如何通过运行 spring boot 测试代码来解决这个问题?