Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-23-2019 05:00 PM
Hi everyone,
Am trying to rename a few thousand relationship types using apoc.refactor.rename.type but keep getting error and am wondering whether this is a bug but wanted to check here first before posting to Github.
This is the query am running ...
MATCH ()-[r:LABELED_AS]->()
WITH collect(r) AS relationships
CALL apoc.refactor.rename.type('LABELED_AS', 'TAGGED_AS', relationships)
YIELD errorMessages AS eMessages
RETURN eMessages
Which keeps producing following error ...
Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure `apoc.refactor.rename.type`: Caused by: java.lang.AssertionError: assertion failed
I did a bit of research but only found the following post which was about apoc.refactor.rename.label but it sounds similar so am now wondering if this is related ...
I ran EXPLAIN, see below, and also tried to run PROFILE but getting same error there.
I also tried to run this as apoc.periodic.iterate but then Neo4j desktop simply crashes ...
CALL apoc.periodic.iterate("MATCH ()-[r:LABELED_AS]->() RETURN r", "CALL apoc.refactor.rename.type('LABELED_AS', 'TAGGED_AS', r) YIELD errorMessages AS eMessages RETURN eMessages", {batchSize:1000, parallel:true})
I also tried to narrow down the MATCH phrase using below but same outcome ...
MATCH (n:Project)-[r:LABELED_AS]->()
Am running Neo4j 3.4.10 on Google Compute Engine with 4 vCPUs, 32 GB memory
Any ideas anyone? What am I doing wrong or is this a bug?
Solved! Go to Solution.
12-23-2019 09:22 PM
It's hard to tell. Why don't you delete all those edges and recreate them again? Something like this:
MATCH (a)-[r:LABELED_AS]->(b)
DELETE r
MERGE (a)-[:TAGGED_AS]->(b)
12-23-2019 09:22 PM
It's hard to tell. Why don't you delete all those edges and recreate them again? Something like this:
MATCH (a)-[r:LABELED_AS]->(b)
DELETE r
MERGE (a)-[:TAGGED_AS]->(b)
12-24-2019 04:02 PM
I guess I could create the new relationships first, check it's all ok and then delete the other ones! Good thinking, thanks!
12-24-2019 05:16 PM
Your cypher runs in a single transaction. So either it succeeds completely or it fails. Don’t worry about about partial failures. Just be careful if you have multiple edges of the same type between 2 nodes. You may delete them all but only create one if not careful.
01-05-2020 07:46 PM
Update: I find wrapping the above into apoc.periodic.iterate
works best and super fast i.e.
CALL apoc.periodic.iterate("
MATCH (n1)-[r:LABELED_AS]->(n2)
RETURN n1, r, n2", "
DELETE r
MERGE (n1)-[:TAGGED_AS]->(n2)
RETURN *",
{batchSize:1000, iterateList:true, parallel:true})
All the sessions of the conference are now available online