Here i am trying to merge all the nodes that are totally identical to each other, but when i execute the below query its throwing error. Can anyone please help me to resolve this issue.
// Step 1: Find pairs of identical nodes (excluding the 'hex_id' property)
MATCH (n1), (n2)
WHERE id(n1) < id(n2)
AND labels(n1) = labels(n2)
AND apoc.map.removeKey(properties(n1), 'hex_id') = apoc.map.removeKey(properties(n2), 'hex_id')
// Step 2: Merge the nodes using APOC procedure
WITH n1, n2
CALL apoc.refactor.mergeNodes([n1, n2], {properties: "overwrite", mergeRels: true})
YIELD node AS merged_node
RETURN id(merged_node) AS merged_node_id
ERROR:
Failed to invoke procedure apoc.refactor.mergeNodes
: Caused by: org.neo4j.graphdb.NotFoundException: Node 15777 not found