2017-06-15 38 views

回答

3

你可以做這樣的事情:

MATCH (a:Node {id:1})-[r:rel]->(b:Node {id:2}) 
WITH collect(r) as rels 
FOREACH (rel in rels[1..] | 
    DELETE rel 
) 

該查詢迭代在從第二匹配關係,最終刪除它們。

作爲替代方案,如果您不想迭代關係,則可以使用APOC procedureapoc.create.relationship。這樣您將刪除所有當前關係並基於排除關係的類型創建一個新關係。

MATCH (a)-[r:rel]->(b) 
DELETE r 
WITH distinct a, b, type(r) as type 
CALL apoc.create.relationship(a, type, {}, b) YIELD rel 
RETURN rel 
相關問題