RedisGraph: Merge nodes and move all the reletionships?

330 views Asked by At

In RedisGraph using Cypher/python is there a way to

Merge two nodes and move all the relationships from the old node to the new node ?

I suspect there are no pure Cypher solution... in that case what will be the equivalent atomic operations and how to combine them to achieve MERGE-nodes+rel

neo4j have apoc.refactor.mergeNodes(nodes, options), apoc.refactor.mergeRelationships(rels, options), but that doesn't help me !:( because I'm using RedisGraph.

the problem is that in RG I dont have lower level access to do enumeration/iteration to do this programmatically !!


this worked in one direction I have to apply -> the reverse <- second time.

    MATCH (old)-[r:q]->(from_to)
    WHERE old.val = $old
    MATCH (new) WHERE new.val = $new
    MERGE (new)-[nr2:q]->(from_to)
    SET nr2.val = r.val
    DELETE r

any way to combine it in single query ?

1

There are 1 answers

2
sentientcabbage On

I think this can be accomplished in pure Cypher:

MATCH (old {val: 'old'})-[e:E]->(old_to)
MERGE (new {val: 'new'})
CREATE (new)-[e2:E]->(old_to)
SET e2.prop1 = e.prop1, [...]
DELETE e

The chief annoyance here is that all of the edge properties (and node properties, if those are also to be migrated) must be set explicitly, as RedisGraph does not currently support setting property maps.