Neo4j node/relation inconsistencies

ⅰ亾dé卋堺 提交于 2019-12-12 19:49:12

问题


When fetching or when I try to delete a specifc node like

MATCH (p) 
where ID(p)=79259223
OPTIONAL MATCH (p)-[r]-() 
//drops p's relations
DELETE r,p

I get the following error

While loading relationships for Node[79259223] a Relationship[87331456] was encountered that had startNode: 80312215 and endNode: 83719851, i.e. which had neither start nor end node as the node we're loading relationships for

I also run the ConsistencyChecker what resulted in a big list of inconsistencys. However how can you fix these inconsistencys? I can not delete the nodes for instance


回答1:


Here is a possible way to "fix" an occurrence of this error. Unfortunately, it is a fairly manual approach that has to be used for every node that encounters the same problem.

Before you delete the node, you can try to delete the inconsistent relationship by its native neo4j ID. For example:

MATCH ()-[r]->()
WHERE ID(r) = 87331456
DELETE r;

NOTE: Before deleting that relationship, you should first try to take a look at it (e.g., replace DELETE WITH RETURN) to understand what you are planning to delete. You may want to do something else first or instead.

If that deletion works, then try to delete the node again, as follows:

MATCH (p) 
WHERE ID(p) = 79259223
DETACH DELETE p;

Notice that I use the DETACH DELETE syntax, which will attempt to delete all the relationships for the specified node.



来源:https://stackoverflow.com/questions/41739860/neo4j-node-relation-inconsistencies

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!