What is the best way to run a multi-statement cypher query?
I would like to run a small cypher query without running transactions in Java etc, simply for partial backup/restore purposes.
As far as I understand this would be done using CSV or cypher. I've extensively tested this.
CSV:
CALL apoc.export.csv.query("MATCH (x:X)-[r:relationship]->(y:Y) RETURN x.x as xx, properties(r) as rr, y.y as yy", "x.csv", {})
Although it's possible to both export, and interpret property maps with APOC, it's not possible to dynamic assign property map (i.e. SET r = {...}); nodes/relationship properties can only be set with explicit labelled assignment, making this method inconvenient for our purpose.
Cypher should have more support, though as I understand export is again only possible using APOC e.g.:
call apoc.export.cypher.query("MATCH (x:X) RETURN *", "x.cypher", {format:'plain', cypherFormat:'updateStructure'})
How can a cypher be imported? I have tried the following:
- all 3 export formats: plain, cypher-shell, neo4j-shell
- drag into neo4j browser cypher import (syntax error is reported on multiple statements, or cypher wrapping)
- using apoc.cypher.runFile in Neo4J Desktop browser (freezes)
- using apoc.cypher.runFile in Linux cypher-shell tool (freezes) e.g.:
cypher-shell -u user -p pass "call apoc.cypher.runFile('x.cypher')"
This seems to simply freeze (for less than 300 relationships/properties - I've waited about 15 minutes, I would expect this to take in the order of milliseconds)
Note contrary to documentation, runFile only works WITHOUT cypher wrapping (BEGIN / :begin etc), using format:'plain'.
Any advise appreciated.
Neo4J 3.5.1: Desktop / Linux