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?
Creating Relationships We can create a relationship using the CREATE clause. We will specify relationship within the square braces “[ ]” depending on the direction of the relationship it is placed between hyphen “ - ” and arrow “ → ” as shown in the following syntax.
You cannot rename an already existing relationship. You'd have to run through all relationships, create the new one in parallel (including all properties) and then remove the old one.
Syntax: Creating relationships When you create the relationship, it must have direction. You can query nodes for a relationship in either direction, but you must create the relationship with a direction.
The graphs in the Neo4j Graph Data Science Library support properties for relationships. We provide multiple operations to work with the stored relationship-properties in projected graphs. Relationship properties are either added during the graph projection or when using the mutate mode of our graph algorithms.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With