cancel
Showing results for 
Search instead for 
Did you mean: 

APOC Rename and Merge Nodes

joaoorreia
Node

Hi Graphistas!

Im running Aura professional and I created a graph which I now have populated with data. Unfortunately I made a small mistake in the node type and now I have two node types: Identifier and identifier.

I want to consolidate them so the strategy is to first rename the identifier to Identifier and then Merge them with mergeRels true.

I created a sample graph and the following queries to perform this transformation

Rename old label

MATCH(i:identifier)
WITH collect(i) AS ids
CALL apoc.refactor.rename.label("identifier", "Identifier", ids)
YIELD committedOperations
RETURN committedOperations

Merge nodes with rels.

MATCH (i:Identifier)
WITH i
WITH i.id AS id, collect(i) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: {`.*`: 'combine'}, mergeRels:true})
YIELD node
RETURN count(*)

When I do this on Neo4j Desktop it works great, when on Aura it doesnt do anything.
Here's the sample graph

CREATE (:Device {id: "device2"})-[:HAS_IDENTIFIER {created_at: 432432, updated_at: 432432}]->(:identifier {id: "A"})<-[:HAS_IDENTIFIER {created_at: 21212121, updated_at: 453543}]-(:Device {id: "device1"}),
(:Device {id: "device33"})-[:_RELATED]->(:identifier {id: "B"}),
(:Identifier {id: "A", propertymustsaved: "true"})

Would appreciate any guidance you have!

Thank you
Joao

1 REPLY 1

tard_gabriel
Ninja
Ninja

You did the exact same mistake in both Aura and Desktop?

The state of your database must be different I guess or do you get any error while using Aura?
Aura doesn't include all the functionnality of apoc full, it's just a core version of apoc but I think merge should be part of it.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.