I am using Neo4j to build a huge graph database (over a million nodes). The way I'm doing it right now is running a cypher CREATE (n {property:'value'})
query for each of the node. As expected, this is quite an inefficient method and it takes lots of time. Can somebody suggest me some alternative method to overcome this issue? I've heard that Neo4j also provides some default batch interface to create multiple nodes. I'm currently using this version of code (including the relationship):
create (a { name: "a" })-[:rel1]->(b {name : "b"}),(c {name: "c"})-[:rel2]->(d {name:"d"}),...
Is it an efficient method or are there any better methods? Thanks in advance! :)
Two alternatives I'd consider:
LOAD CSV
support: http://docs.neo4j.org/chunked/stable/query-load-csv.html
Otherwise there is the batch inserter, as mentioned.
There is an overview on the Neo4j website: http://www.neo4j.org/develop/import
But to be short, for more than a million nodes I would say:
If you can code in Java:
http://docs.neo4j.org/chunked/stable/batchinsert.html
else:
https://github.com/jexp/batch-import
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With