Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-09-2019 08:38 AM
Hello Everyone
I just want to know how I can change the name of relationships in neo4j. I have many relationships that have label "IS_CONNECTED_TO". Right now I want to substitute them all with "KNOWS". Does anybody know how I can do it?
Thanks
04-09-2019 09:05 AM
You cannot rename a relationship, but you can create a new one and delete the old one.
So you could do something like this:
MATCH (n)-[rel:IS_CONNECTED_TO]->(m)
MERGE (n)-[:KNOWS]->(m)
DELETE rel
If the relationship has properties, then you would need to add them when you merge.
Elaine
04-10-2019 12:45 AM
Thanks Elaine, it worked
12-02-2020 11:50 PM
what if in case of condition in where clause in relation ship
04-09-2019 12:25 PM
Use APOC Refactoring:
MATCH (n)-[rel:IS_CONNECTED_TO]->(m) WITH rel
CALL apoc.refactor.setType(rel, 'KNOWS') YIELD input, output RETURN *
Result:
MATCH (n)-[:KNOWS]->(m)
04-10-2019 12:46 AM
Hi Ameyasoft
I am not very familiar yet with APOC. but your advice encouraged me to start and learn APOC. Thank you very mucj
09-30-2022 04:52 AM
Hey Ameya, This helped me a lot. Thank you.
Could kindly share how to change the Node Label Name (Constraint) using APOC ?
All the sessions of the conference are now available online