Best way to export results of a query into a new database

I'm trying to export the results of a cypher query (nodes and relationships) into a new database, because I want a subset of my database that uses less memory for a large query. I found this: Export to Cypher Script - APOC Extended Documentation but it doesn't bring back all the relationships(Apoc.export.cypher.query not creating all relationships that were exported). Is there a better way to do this? Thanks!


Hi Oleg
Please after export it as a. dump file so that you can reimport it in your brand new cluster/node configuration. Also please make sure that admin command line tool is installed so that you can successfully invoke admin import copy or similar commands.
Thanking you

Hi @sameer.gijare14 is it possible to make a .dump file of just a query? I don't need the whole database, just the results of a query? Do you have a link with instructions?

Try using apoc.export.json.query:
CALL apoc.export.json.query(
"MATCH (c)-[r]-(d)-[r1]-(b)-[r2]-(f) 
with collect(distinct c) + collect(d) + collect(b) + collect(f) as nodes, 
collect(r) + collect(r1) + collect(r2) as relationships 
RETURN nodes, relationships", null, {stream: true}) YIELD data 


1 Like

I ended up using the graphml version of the export and import, and it worked fine, I got all my nodes and relationships.

Still not sure why the apoc.export.cypher.query version didn't work on import and missed all the relationships.

1 Like

Hi Oleg
There is a command known as call graph. db. schema.export(Cypher query).
Thanking you
Yours faithfully
Sameer S Gijare