我的密码出了什么问题。完整描述在标题中。
match (p:P)<-[r:LINK]-(:G)
with r, count(r) as num
where num > 100
delete r
答案 0 :(得分:1)
在计算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