相关疑难解决方法(0)

使用 Cypher 在 Neo4j 中查询递归关系链

我有一个图形数据库,它正在对消息的元数据和可以包含在这些消息中的字段进行建模。其中一些字段可以是“组”,它们是其他字段的组。我试图问 Neo 的是“哪些消息正在使用这个组?”。以下是可用于从消息获取到组的路径类型列表:

message-[:INLINE]->group  (the fields of a group are used inline on a message)
message-[:FIELDREF]->(fref)-[:FIELD]->(field)-[:DATATYPE]->group (the group is used as a data type by a field on the message)
Run Code Online (Sandbox Code Playgroud)

第二个链是递归的。换句话说,-[:FIELDREF]->(fref)-[:FIELD]->(field)-[:DATATYPE]-(group) 段可以一遍又一遍地发生,然后最终到达我感兴趣的组在。

所以,我想知道的是,我如何在路径中的每个单独元素上要求重复的关系链,而不仅仅是多个(例如,关系名称后面的 *)?

回顾一下,您可以通过遍历 [:INLINE] 关系从消息进入组,然后可以遵循 n 个“fieldref-field-datatype-group”链。或者您可以从通过遍历 n 个“fieldref-field-datatype-group”链来获取消息。

START group=node({sourceGroupId})
... ? ? ? ...
Run Code Online (Sandbox Code Playgroud)

所以我想要像 [?:INLINE]-> 0..n of (fieldref-field-datatype-group) 链。

有什么想法吗?

neo4j relationships cypher

2
推荐指数
1
解决办法
6068
查看次数

标签 统计

cypher ×1

neo4j ×1

relationships ×1