当使用可变长度路径时,Neo4J Cypher抓住了关系类型

时间:2023-01-19 18:02:30

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. How would I grab the name (type) of r1 as return from the query?

cypher命令类型对于没有可变长度路径的关系有效,但即使它们具有相同的名称也对有效路径无效。如何从查询中获取r1的名称(类型)?

Thanks, B

1 个解决方案

#1


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;

#1


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;