Importing data from one Neo4j server to another server (Copy Entire Subgraph)

Viewed 33

I want to copy entire subgraph from one server to another server via a cypher in Neo 4j . I have a Neo 4j on Host 1 and another Neo 4j on Host 2 . My requirement to copy the graph from Host 1 and insert into Host 2

1 Answers

You can use apoc.bolt.execute procedure to move data from one graph to another graph :

Here is an example moving data from the standard movies graph to another graph called movies888 :

Replace username, password and host with your values

MATCH (n:Person)-[r:ACTED_IN]->(m)
WITH n, r, m
CALL apoc.bolt.execute(
    'bolt://<username>:<password>@<host>:7687',
    '
        MERGE (p:Person {name: $n.name}) SET p = $n
        MERGE (m:Movie {title: $m.title}) SET m = $m
        MERGE (p)-[r:ACTED_IN]->(m)
        SET r = $r
    ',
    {n: n{.*}, m: m{.*}, r: r{.*}}, {databaseName: 'movies888'}
)
YIELD row RETURN count(*)
Related