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}

demandé il y a 2 ans385 vues
1 réponse
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
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions