简体   繁体   English

使用可变长度路径时Neo4J Cypher抓取关系的类型

[英]Neo4J Cypher grabbing type of relations when using variable length paths

query: 查询:

Match (d:User {name:"User"}) -[r:IS_MEMBER_OF]->(g:Group:Local) - [r1:IS_SUBGROUP_OF*0..]->(g1:Group) Return type(r), type(r1)

the cypher command type is valid for the relation without variable length paths but not valid for the variable ones even when they have the same name. cypher命令类型对没有可变长度路径的关系有效,但对变量路径无效,即使它们具有相同的名称。 How would I grab the name (type) of r1 as return from the query? 如何从查询中获取r1的名称(类型)?

Thanks, B 谢谢,乙

Unfortunately, there seems to be a bug in version 2.2.1 (and maybe some earlier versions) that prevents this from working: 不幸的是,似乎在版本2.2.1(可能还有一些早期版本)中存在一个错误 ,阻止了该错误的发生:

MATCH (:User { name:"User" })-[r:IS_MEMBER_OF]->(:Group:Local)-[r1:IS_SUBGROUP_OF*0..]->(:Group)
RETURN type(r), EXTRACT(rel IN r1 | type(rel)) AS ancestorGroupTypes;

So, this is a workaround until the above simpler query works again: 因此,这是一个解决方法,直到上述更简单的查询再次起作用:

MATCH p=(:User {name:"User"})-[r:IS_MEMBER_OF]->(:Group:Local)-[r1:IS_SUBGROUP_OF*0..]->(:Group)
Return type(r), EXTRACT (rel IN TAIL(RELATIONSHIPS(p)) | type(rel)) AS ancestorGroupTypes;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM