Search code examples
rediscypherredisgraph

How to remove/delete duplicate nodes from RedisGraph


Can someone help me on deleting duplicate nodes from the RedisGraph for a particular label. I found cypher queries in Neo4j, but the are not supporting in Redis. Please help me on this.

I used below query, then RedisInsight thrown error

MATCH (p:Person)
WITH p.id as id , collect(p) AS nodes 
WHERE size(nodes) >  1
RETURN [ n in nodes | n.id ] AS ids, size(nodes)
ORDER BY size(nodes) DESC

Error: RedisGraph does not currently support list comprehension


Solution

  • To delete duplicates you can use the following

    MATCH (p:Person)
    WITH p.id as id, collect(p) AS nodes 
    WHERE size(nodes) >  1
    UNWIND nodes[1..] AS node
    DELETE node