CREATE UNIQUE in neo4j produces duplicate nodes

前端 未结 2 2007
花落未央
花落未央 2021-01-22 14:45

According to the neo4j documentation:

CREATE UNIQUE is in the middle of MATCH and CREATE — it will match what it can, and create what is missing. CREATE

2条回答
  •  面向向阳花
    2021-01-22 15:09

    This query should do what you want (if you always want to end up with a single knows relationship between the 2 nodes):

    MATCH (a:Person {name: 'Alice'})
    MERGE (b:Person {name: 'Bob'})
    MERGE (a)-[:knows]->(b)
    RETURN a;
    

提交回复
热议问题