1

On my AWS hosted Neo4j server I have a large dataset ingested. Versions in use are neo4j:3.5.5-enterprise and apoc-3.5.0.4. I want to examine a subset of the dataset on my laptop, so I want to export the subset and create my data.cypher file like this:

call apoc.export.cypher.query(
"
MATCH (a:Author {name: '$NAME'})
WITH a
OPTIONAL MATCH (u:UnknownAuthor)-[:MAYBE]-(a)
WITH collect(u)+collect(a) AS authors
UNWIND authors as a
MATCH (a)-[:WROTE]-(p:Paper)
WITH a, p
OPTIONAL MATCH (p)-[]-(n)
return *
",
'/data.cypher',{format:'cypher-shell'});

Both the AWS and my local Neo4j run in Docker containers. So I retrieve it from the Docker container

docker cp neo4j:/var/lib/neo4j/import/data.cypher data.cypher

Then I download the data.cypher file to my laptop and attempt to ingest it into my local, empty Neo4j container:

docker cp data.cypher neo4j:/var/lib/neo4j/import/data.cypher

echo "starting cypher shell"
docker exec -it neo4j \
    sh -c 'cat /var/lib/neo4j/import/data.cypher | /var/lib/neo4j/bin/cypher-shell --format plain'

Unfortunately this doesn't work and I receive this error message:

Invalid input '}': expected whitespace, comment or a property key name (line 2, column 61 (offset: 61))
"UNWIND [{id:"3647617", properties:{name:"Allen Macpherson", }}, {id:"47022847", properties:{name:"Julia E. Anderson", }}, --- REST OMITTED ---] as row"
                                                              ^

How can I import this file?

oschlueter
  • 2,596
  • 1
  • 23
  • 46
  • I also tested passing `format:'neo4j-shell'` and `format:'plain'` to `apoc.export.cypher.query` to no avail. The `plain`-formatted file throws the same error and the `neo4j-shell`-formatted file fails at the `BEGIN` keyword in the file. – oschlueter Jul 23 '19 at 20:35
  • 1
    Seems like the Cypher in `data.cypher` is malformed. If the file actually contains the data shown in the error message, then there may be a bug in `apoc.export.cypher.query`. This recently fixed bug may be related: https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/1209 – cybersam Jul 23 '19 at 20:36
  • `docker exec -it neo4j grep 47022847 /var/lib/neo4j/import/data.cypher` returns `UNWIND [{id:"3647617", properties:{name:"Allen Macpherson", }}, {id:"47022847", properties:{name:"Julia E. Anderson", }}, --- REST OMITTED ---] as row`. So I guess I should file a bug report then....? – oschlueter Jul 23 '19 at 20:42
  • 1
    Thanks for point out that bug report @cybersam! I repaired the file using `sed 's/, }}/ }}/g' data.cypher > repaired.cypher` – oschlueter Jul 23 '19 at 20:57

0 Answers0