Search code examples
neo4jcypher

Find duplicate nodes neo4j


I want to find all duplicate nodes per type in a neo4j database

Example : i have node1 with properties : name,adress,phone i wan't to match all nodes that are duplicated without specifying the properties names in the query


Solution

  • You can try this as well:

    Match (n1:Person)
    Match (n2:Person) Where id(n1) <> id(n2) and properties(n1)=properties(n2)
    RETURN n1, n2
    

    To ignore certain properties, try something like this:

    WITH ['author', 'location', 'traceId'] AS ignoredProperties
    Match (n1:Person)
    Match (n2:Person) Where id(n1) <> id(n2) and ALL(x IN keys(properties(n1)) WHERE x IN ignoredProperties OR n1[x] = n2[x])
    RETURN n1, n2