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}

asked a year ago363 views
1 Answer
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
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions