Batch insert

andreasronge edited this page Jan 12, 2013 · 3 revisions
Clone this wiki locally

The Neo4j batch inserter Java API is not wrapped in a Ruby API (it was supported in 1.x version of neo4j.rb).

I would suggest first try without the batch inserter api and make sure you only commit after each 1000-3000 write operation.

Here is an helper class

Example of usage

t = do |data| # or use your model classes (the Neo4j::Rails::Model) which might be slower

t.execute([{:name => 'a'}, {:name => 'b'}]

If you want to use the neo4j gem but insert using the neo4j-core API (because of speed) you must make sure you set the _classname property and create relationships from the Neo4j.ref_node to class node and from the class not relationship _all to all instances.

If you still have performance problem, I would suggest using the Java Batch api directly, see for examples