cypher删除关系数大于数的所有节点关系

问题描述:

我的密码有什么问题。完整的描述在标题中。cypher删除关系数大于数的所有节点关系

match (p:P)<-[r:LINK]-(:G) 
with r, count(r) as num 
where num > 100 
delete r 

您骨料r计数r时,这意味着每一行都会有一个计数的准确1.

为了解决这个问题,你应该为聚合p

match (p:P)<-[r:LINK]-(:G) 
with p, count(r) as num 
where num > 100 
match (p)<-[r:LINK]-(:G) 
delete r 

另一个选项是collect与列表的关系,unwind对于选定的关系:

match (p:P)<-[r:LINK]-(:G) 
with p, count(r) as num, collect(r) as rs 
where num > 100 
unwind rs as r 
delete r 

如果使用这种方法,你不妨忽略count(r)和检查rs集合的大小:

match (p:P)<-[r:LINK]-(:G) 
with p, collect(r) as rs 
where size(rs) > 100 
unwind rs as r 
delete r 
+0

但如果我这样做的,变量R没有定义了 – user732456

+0

你对。要解决这个问题,请使用另一个“匹配” - 我相应地编辑了我的答案。 –

+0

仍然没有结果。在“匹配(p:P) user732456