获取具有超过 X 关系的节点及其特定格式的子节点
Get nodes having more than X relationships and it's children in specific format
我有这个 Cypher 查询:
MATCH (Parent)-[R1]-(Child)
MATCH (Child)-[R2]-(Grandchild)
WHERE ID(Parent)=238777
RETURN Parent, Child, type(R1) as R, count(R2) as Degree
其中 returns 这种格式的数据:
Parent | Child | Relationship name | Degree of child (how many relationship child has)
我现在想做的是找出所有超过X个关系的节点,并以相同的格式显示结果。
我目前有这个查询:
MATCH (Parent:FullAddress)-[r]-(Child)
MATCH (Child)-[R2]-(Grandchild)
WITH Parent, count(r) as childrenCount, collect(Child) as ChildrenList, r
WHERE childrenCount > 10
UNWIND ChildrenList as ChildrenSeparate
RETURN Parent, ChildrenSeparate, type(r)
其中 returns 这种格式的数据:
Parent | Child | Relationship name
关于如何添加 degree
功能有什么建议吗?
原来有一个名为 APOC(Awesome Procedures on Cypher)的库,它有很多非常酷的功能。其中之一是 degree
函数。
如果您 运行 遇到类似问题,请查看此内容。它大大简化了我的查询!
我有这个 Cypher 查询:
MATCH (Parent)-[R1]-(Child)
MATCH (Child)-[R2]-(Grandchild)
WHERE ID(Parent)=238777
RETURN Parent, Child, type(R1) as R, count(R2) as Degree
其中 returns 这种格式的数据:
Parent | Child | Relationship name | Degree of child (how many relationship child has)
我现在想做的是找出所有超过X个关系的节点,并以相同的格式显示结果。
我目前有这个查询:
MATCH (Parent:FullAddress)-[r]-(Child)
MATCH (Child)-[R2]-(Grandchild)
WITH Parent, count(r) as childrenCount, collect(Child) as ChildrenList, r
WHERE childrenCount > 10
UNWIND ChildrenList as ChildrenSeparate
RETURN Parent, ChildrenSeparate, type(r)
其中 returns 这种格式的数据:
Parent | Child | Relationship name
关于如何添加 degree
功能有什么建议吗?
原来有一个名为 APOC(Awesome Procedures on Cypher)的库,它有很多非常酷的功能。其中之一是 degree
函数。
如果您 运行 遇到类似问题,请查看此内容。它大大简化了我的查询!