neo4j cypher: how to change the type of a relationship

Sovos picture Sovos · Mar 26, 2014 · Viewed 15.1k times · Source

I can't find a way to change a relationship type in Cypher. Is this operation possible at all? If not: what's the best way achieve this result?

Answer

Michael Hunger picture Michael Hunger · Mar 26, 2014

Unfortunately there is no direct change of rel-type possible at the moment.

You can do:

MATCH (n:User {name:"foo"})-[r:REL]->(m:User {name:"bar"})
CREATE (n)-[r2:NEWREL]->(m)
// copy properties, if necessary
SET r2 = r
WITH r
DELETE r