I have an XML file with the following pattern: nodes with the ref property have the same value as the id property of other nodes. This is a visual example in Neo4j:
The yellow one has the ref property (ref=2) value as TWO (id=2).
My goal is to create a graph, deleting each node with the ref value that is equal to other id nodes, but also preserving the relationship isFatherOf that has to point to the other node, in this case, TWO.
Here is the outcome of the procedure:
I'm able to delete all the ref nodes with the following procedure,
match (n1:Node)
with collect(distinct n1.id) as ids
collection called 'ids'
match (n2:Node)
where n2.ref in ids
detach delete n2
but I do not know how to preserve the relationships. Is there a way to do that?