Skip to content

Instantly share code, notes, and snippets.

@felixebert
Created April 10, 2017 14:36
Show Gist options
  • Save felixebert/3d7eb2ef27a42065a1d521bb23c9e9c5 to your computer and use it in GitHub Desktop.
Save felixebert/3d7eb2ef27a42065a1d521bb23c9e9c5 to your computer and use it in GitHub Desktop.
Import of large JSON file into neo4j using apoc
CALL apoc.periodic.iterate("
CALL apoc.load.json('file:///Users/f/source/companies.json')
YIELD value UNWIND value.rows AS row RETURN row
", "
MERGE (c:Company {id: row.id})
ON CREATE SET c.id = row.id, c.name = row.name
WITH row
UNWIND row.relatedPersons as item
MERGE (p:Person {id: item.person.id})
ON CREATE SET p.id = item.person.id, p.name = item.person.name
MERGE (c)-[:RELATED {role: item.role.type}]-(p)
", {batchSize: 10000, iterateList: true});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment