Neo4j节点/关系不一致 [英] Neo4j node/relation inconsistencies

查看:193
本文介绍了Neo4j节点/关系不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取或尝试删除特定的节点时

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

我收到以下错误

在为节点[79259223]加载关系时,遇到了一个关系[87331456],其具有startNode:80312215和endNode:83719851,即,既没有开始节点,也没有结束节点作为我们正在为其加载关系的节点

我还运行ConsistencyChecker,这导致了一大堆不一致之处.但是,如何解决这些不一致之处?我无法删除实例节点

解决方案

这是可能的一种方法,用于修复"此错误的发生.不幸的是,这是一种相当手动的方法,必须用于遇到相同问题的每个节点.

在删除节点之前,您可以尝试通过其本机neo4j ID删除不一致的关系.例如:

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

注意:在删除该关系之前,您应该首先尝试看看它(例如,将DELETE替换为RETURN),以了解您打算删除的内容.您可能想先做别的事情.

如果该删除有效,请尝试再次删除该节点,如下所示:

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

请注意,我使用了DETACH DELETE语法,该语法将尝试删除指定节点的所有关系.

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

解决方案

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.

这篇关于Neo4j节点/关系不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆