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 年前檢視次數 385 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南