Neptune: Duplicate nodes created for single open cypher Create statement.

0

I have java based application, which load csv files and insert into to Graph db. the application works fine with Neo4j and now we are trying to support Neptune using Cypher. the problem I ran is that Neptune created duplicate node (with difference id (Neptune's internal id)) with one cypher create statement. I am wondering anyone run into similar issue. this issue is intermittent and random.

running query CREATE (n: Person {firstName: $firstName,lastName: $lastName,dateCreated: $dateCreated,UniqueID: $uniqueID }) with param {firstName=D, lastName=Gordon, dateCreated=1665678784432, uniqueID=Person:30efd386-20ef-4284-b73a-143acd1b4eac}

已提问 2 年前386 查看次数
1 回答
0

While there is not enough information to determine what happened here, and since two nodes were created with different ID values the most likely culprit was something inside your Java application called the CREATE query multiple times, maybe as part of retry logic. If you want to ensure that a value is only added a single time, you should investigate using the MERGE clause, which will perform an upsert operation based on the matching criteria you specify. In the example below, I am matching on UniqueId

MERGE (n:Person)
WHERE UniqueID=$uniqueId
ON CREATE
  SET n = {firstName: $firstName,lastName: $lastName,dateCreated: $dateCreated,UniqueID: $uniqueID }
AWS
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则