It is possible to use MERGE
instead of CREATE UNIQUE
, perhaps even preferred. What you need to do is to MERGE
by uniqueReference like so:
Load CSV from ...
MATCH (sender:Wallet {primWallAddr:line[0]}), (receiver:Wallet {primWallAddr:line[1]})
MERGE (sender)-[:SendTo{tranHashString:line[2],...uniqueReference:(line[2])}]->(receiver)
Slightly more optimized would be MERGE
on unique reference and set additional properties with ON CREATE
Load CSV from ...
MATCH (sender:Wallet {primWallAddr:line[0]}), (receiver:Wallet {primWallAddr:line[1]})
MERGE (sender)-[s:SendTo{uniqueReference: line[2]]->(receiver)
ON CREATE SET s.tranHashString = line[3]
If you wanted to have only one relationship between this sender and receiver and just update its properties you would use:
Load CSV from ...
MATCH (sender:Wallet {primWallAddr:line[0]}), (receiver:Wallet {primWallAddr:line[1]})
MERGE (sender)-[s:SendTo]->(receiver)
ON CREATE SET s.tranHashString = line[3]
ON MATCH SET s.tranHashString = line[3]
Answer to question 1 :
Yes from what I understand you can use CREATE UNIQUE
in your case, just know that if you want to change any property of the relationship, CREATE UNIQUE
will create a new relationship and never update existing, which will ruin your ID system.