Created
April 10, 2017 14:36
-
-
Save felixebert/3d7eb2ef27a42065a1d521bb23c9e9c5 to your computer and use it in GitHub Desktop.
Import of large JSON file into neo4j using apoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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