首页 > 解决方案 > 无法创建 CONSTRAINT ON (___neo4jgraphs:___neo4jgraphs)

问题描述

我正在尝试将使用Cypher-for-Apache-Spark项目从Spark- dataframes 创建的图形存储到neo4j中。

当我运行我的代码时:您可以在 github 问题的最后一条评论中找到它

我收到此错误:

Exception in thread "main" org.neo4j.driver.v1.exceptions.DatabaseException: Unable to create CONSTRAINT ON ( ___neo4jgraphs874:___neo4jgraphs874 ) ASSERT ___neo4jgraphs874.___morpheusID IS UNIQUE:
Both Node(57) and Node(74) have the label `___neo4jgraphs874` and property `___morpheusID` = 4

任何人都知道为什么会这样?

标签: apache-sparkneo4j

解决方案


在这里解决了 我已经弄清楚了问题所在:由于数据帧具有相同的 ID 号,因此触发了此错误:

df1||df2||df3
 0L||0L ||0L
 1L||1L ||1L
 2L||2L ||2L

要修复每个数据帧,它的 id 必须与另一个不同:

df1||df2||df3
0L||3L  ||6L
1L||4L  ||7L
2L||5L  ||8L 

推荐阅读