Log in Register now

Neo4j duplicates removing with Cypher

This approach allows to delete all duplicate nodes with their relationships.

START project=node(123)
MATCH project-[:T]->tA<-[:F]-jA
WITH project, MIN(ID(jA)) AS minId
MATCH project-[:T]->tB<-[:F]-jB
WHERE ID(jB)>minId
WITH jB
MATCH jB-[r]-()
DELETE jB,r

In the result we will have one single node without duplicates.

UPD. The idea was good, but it not works as desired.

comments (0)

Only registered users can add comments. Please, Login or Register.