Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

neo4j cypher: how to change the type of a relationship

Tags:

neo4j

cypher

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?

like image 617
Sovos Avatar asked Mar 26 '14 18:03

Sovos


People also ask

How do you add a relationship type in Neo4j?

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.

How do I change my relationship name in Neo4j?

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.

When you create a relationship in Cypher You must specify a direction True or false?

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.

Can relationships have properties in Neo4j?

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.


1 Answers

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 
like image 56
Michael Hunger Avatar answered Sep 22 '22 01:09

Michael Hunger