Skip to content

Instantly share code, notes, and snippets.

@alexbilbie
Created October 14, 2013 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexbilbie/6976275 to your computer and use it in GitHub Desktop.
Save alexbilbie/6976275 to your computer and use it in GitHub Desktop.
Find nodes with duplicate properties
// Replace <INDEX> and <PROPERTY>
START n=node:<INDEX>('*:*')
WITH n
ORDER BY id(n) DESC // Order by descending to delete the most recent duplicated record
WITH n.<PROPERTY>? as DuplicateKey, COUNT(n) as ColCount, COLLECT(id(n)) as ColNode
WITH DuplicateKey, ColCount, ColNode, HEAD(ColNode) as DuplicateId
WHERE ColCount > 1 AND (DuplicateKey is not null) AND (DuplicateId is not null)
WITH DuplicateKey, ColCount, ColNode, DuplicateId
ORDER BY DuplicateId
RETURN DuplicateKey, ColCount, DuplicateId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment