0
我的密码有什么问题。完整的描述在标题中。cypher删除关系数大于数的所有节点关系
match (p:P)<-[r:LINK]-(:G)
with r, count(r) as num
where num > 100
delete r
我的密码有什么问题。完整的描述在标题中。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
但如果我这样做的,变量R没有定义了 – user732456
你对。要解决这个问题,请使用另一个“匹配” - 我相应地编辑了我的答案。 –
仍然没有结果。在“匹配(p:P)< - [r:LINK] - (:G)返回p,count(r)作为num order by num desc limit(25)”后仍然返回结果“仍然返回计数超过1000的结果 – user732456