1

the following query will create (n1)->(n2) pair. If the nodes already exists they will be reused.

   match (n1:X),(n2:X) where n1.val = 11 and n2.val = 12 
   merge (n1)-[x:q {val: 0 }]->(n2)

the problem is that if the edge with x.val that is different will create new connection.

Is there a way to disregard it ?

I want a single Query, which sets the value first time its called and afterwards ignore the value... OR I have to have two different queries one to set the pair and second w/o x.val that will just merge ?


this seem to work, but i would hear other possibilities :

        on create set x.val = 0.001
sten
  • 7,028
  • 9
  • 41
  • 63

1 Answers1

1

MERGE has a ON CREATE clause that you can use :

MATCH (n1:X),(n2:X) WHERE n1.val = 11 and n2.val = 12 
MERGE (n1)-[x:q]->(n2)
ON CREATE SET x.val = 0
Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36