cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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

oleg_neo4j
Graph Buddy

Hi,
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 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!

Oleg

5 REPLIES 5

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
Sameer

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 

RETURN data


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.

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