Reputation: 554
I have two nodes A and B. They have a relationship R, with some property P, on this relationship.
How I can update this relationship R, with a new value for P? I tried merge, but this creates a new relationship, but I want to update the existing one.
Upvotes: 5
Views: 16510
Reputation: 302
Match (a:A), (b:B) Merge (a)-[r:YourRelations]->(b) Set r.P="new Prop" Return r
Upvotes: 3
Reputation: 30397
Match on your nodes and the relationship, then use SET to update the relationship property. For example:
MATCH (a {name:"A"})-[r]-(b {name:"B"})
SET r.P = "bar"
It's generally best, when looking up specific nodes, to use labels in the query, and have an index or unique constraint (whichever makes the most sense) to speed up your lookups.
Upvotes: 19