Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何删除具有重复属性的Neo4j节点?_Neo4j_Cypher - Fatal编程技术网

如何删除具有重复属性的Neo4j节点?

如何删除具有重复属性的Neo4j节点?,neo4j,cypher,Neo4j,Cypher,在Neo4j 2.1.6中,我有一些节点在某个属性方面是非唯一的,inputID 使用Cypher,如何删除给定属性中重复的所有节点,只留下唯一节点 我试过以下方法 MATCH (n:Input) WITH n.inputID, collect(n) AS nodes WHERE size(nodes) > 1 FOREACH (n in tail(nodes) | DELETE n) …但它会导致 Expression in WITH must be aliased (use AS)

在Neo4j 2.1.6中,我有一些节点在某个属性方面是非唯一的,
inputID

使用Cypher,如何删除给定属性中重复的所有节点,只留下唯一节点

我试过以下方法

MATCH (n:Input)
WITH n.inputID, collect(n) AS nodes
WHERE size(nodes) > 1
FOREACH (n in tail(nodes) | DELETE n)
…但它会导致

Expression in WITH must be aliased (use AS) (line 2, column 6)
"WITH n.inputID, collect(n) AS nodes"
      ^
谢谢


G

您没有将
变量混淆。更改此项:

WITH n.inputID, collect(n) AS nodes
为此:

WITH n.inputID AS inputID, collect(n) AS nodes

正如您正确发现的那样,在集合上使用tail将允许您删除重复项,不要忘记删除节点之前的关系(分离),并将字段别名为所述的Frobberofits:

MATCH (n:Input)
WITH n.inputID AS inputID, collect(n) AS nodes
WHERE size(nodes) > 1
FOREACH (n in tail(nodes) | DETACH DELETE n)

这并不能回答这个问题。一旦你有足够的钱,你将能够;相反是的,我想对FrobberOfBits的答案发表评论,添加“分离”部分,但由于声誉问题,我无法发表评论,我确实将其作为一个注释,但一些“Liam”删除了我的注释。