似乎这个密码代码会导致此错误:此事务中已删除节点xxx。
MATCH (a:Address), (b:Address), (a)-[r:BelongTo]->(:Wallet), (b)-[:BelongTo]->(:Wallet)
WHERE a.AddId=b.AddId AND ID(a) > ID(b)
WITH r, a, b, a {.*, rel: r {.*, type:type(r)}} as snapshot
DELETE r
WITH a, b, snapshot ------------------*
DELETE a -------------------*
WITH b, snapshot
MERGE (c:Address {uniqueReferenceAddr:(...)})
ON CREATE SET c.AddId=snapshot.AddId,..."
WITH c, b, snapshot
MATCH (wa:Wallet) WHERE snapshot.rel.primWallAddr=wa.primWallAddr
MERGE (c)-[r:BelongTo{uniqueReferenceBelongTo:(c.AddId + wa.primWallAddr)}]->(wa)
ON CREATE SET r.primWallAddr = wa.primWallAddr
WITH c, b
MATCH (b)-[r0:BelongTo]->(wa:Wallet)
WITH wa, c, b, r0
MERGE (c)-[r1:BelongTo{uniqueReferenceBelongTo:(c.AddId + wa.primWallAddr)}]->(wa)
ON CREATE SET r1.primWallAddr = wa.primWallAddr
WITH b, r0
DELETE r0
WITH b
DELETE b
当删除标有*的两行时,抛出此错误:无法删除节点xxx(与前面提到的错误中的ID相同),因为仍然存在与之关联的关系。 (沿着那条线的东西)
可能相关的数据:
(id:13557)
primWallAddr 1MEe2mebed8wopvy8xyjjHcEQHUPVJn2UC
multiExist false
first_seen 2014-09-29T20:03:42
addr_tag_link null
last_seen 2017-02-03T05:48:14
addr_tag null
uniqueReferenceAddr 1ERfjthAH9T3PDtFcpkzudha89ABkD9RgSnullnull1MEe2mebed8wopvy8xyjjHcEQHUPVJn2UCfalse
AddId 1ERfjthAH9T3PDtFcpkzudha89ABkD9RgS
b: (id: 13563)
primWallAddr 1KumbRsTcA6UNqU2MHEfqEFnAZYU3w3izR
multiExist false
first_seen 2014-09-29T20:03:42
addr_tag_link null
last_seen 2017-02-03T05:48:14
addr_tag null
uniqueReferenceAddr 1ERfjthAH9T3PDtFcpkzudha89ABkD9RgSnullnull1KumbRsTcA6UNqU2MHEfqEFnAZYU3w3izRfalse
AddId 1ERfjthAH9T3PDtFcpkzudha89ABkD9RgS
(id: 13564)
primWallAddr 1Lsqcv4cg5zUctNi2qwNxMkrv1GeBboSUJ
multiExist false
first_seen 2014-09-29T20:03:42
addr_tag_link null
last_seen 2017-02-03T05:48:14
addr_tag null
uniqueReferenceAddr 1ERfjthAH9T3PDtFcpkzudha89ABkD9RgSnullnull1Lsqcv4cg5zUctNi2qwNxMkrv1GeBboSUJfalse
AddId 1ERfjthAH9T3PDtFcpkzudha89ABkD9RgS
此处显示的所有节点都是地址节点,所有这些节点都与一个(且只有一个)称为:BelongTo
的钱包节点有关系。
设置地址和钱包节点的约束:
CREATE CONSTRAINT ON (addr:Address) ASSERT addr.uniqueReferenceAddr IS UNIQUE
CREATE CONSTRAINT ON (wa:Wallet) ASSERT wa.primWallAddr IS UNIQUE
用于生成地址节点的Cypher代码:
LOAD CSV... as line
MERGE (a:Address {uniqueReferenceAddr:(...)})
ON CREATE SET a.AddId=line[0],...
用于生成钱包节点的Cypher代码:
LOAD CSV... as line
MERGE (w:Wallet { primWallAddr:line[0]})
ON CREATE SET w.first_seen = line[1]...
用于将地址节点链接到相应钱包节点的Cypher代码:
MATCH (addr:Address), (wa:Wallet) WHERE addr.primWallAddr=wa.primWallAddr
MERGE (addr)-[r:BelongTo{uniqueReferenceBelongTo:(...)}]->(wa)
ON CREATE SET ...
在运行这三个查询后运行第一个查询。
有没有人知道是什么原因?