You can use the Apoc from neo4j to extract the data in the form of CSV file. and after you have exported you can import the data into the apache age.
Let's assume we have this movies dataset:
CREATE (TheMatrix:Movie {title:'The Matrix', released:1999, tagline:'Welcome to the Real World'})
CREATE (Keanu:Person {name:'Keanu Reeves', born:1964})
CREATE (Carrie:Person {name:'Carrie-Anne Moss', born:1967})
CREATE (Laurence:Person {name:'Laurence Fishburne', born:1961})
CREATE (Hugo:Person {name:'Hugo Weaving', born:1960})
CREATE (LillyW:Person {name:'Lilly Wachowski', born:1967})
CREATE (LanaW:Person {name:'Lana Wachowski', born:1965})
CREATE (JoelS:Person {name:'Joel Silver', born:1952})
CREATE
(Keanu)-[:ACTED_IN {roles:['Neo']}]->(TheMatrix),
(Carrie)-[:ACTED_IN {roles:['Trinity']}]->(TheMatrix),
(Laurence)-[:ACTED_IN {roles:['Morpheus']}]->(TheMatrix),
(Hugo)-[:ACTED_IN {roles:['Agent Smith']}]->(TheMatrix),
(LillyW)-[:DIRECTED]->(TheMatrix),
(LanaW)-[:DIRECTED]->(TheMatrix),
(JoelS)-[:PRODUCED]->(TheMatrix);
Now for exporting this data in csv format:
CALL apoc.export.csv.all("movies.csv", {})
We can use different functions from Neo4j like "apoc.export.csv.data" or "apoc.export.csv.query" to export data in the form of separate labels and edges files. Once we have the data in labels and edges form we can use that to import it in Apache Age.
Importing data in Apache Age:
We can load the labels from file using this command:
load_labels_from_file('<graph name>',
'<label name>',
'<file path>',
false)
#The fourth parameter is optional, use this only when you have no id field in file.
The CSV format for this file is as follows:
id - properties
The id column will be exempted if we have given the fourth parameter and it's false.
For loading relationships, this function will be used:
load_edges_from_file('<graph name>',
'<label name>',
'<file path>');
The CSV format for this file is as follows:
start_id - start_vertex_type - end_id - end_vertex_type - properties