Created
October 14, 2013 14:10
-
-
Save alexbilbie/6976275 to your computer and use it in GitHub Desktop.
Find nodes with duplicate properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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