Skip to content
andreasronge edited this page Jan 12, 2013 · 3 revisions

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 instead using only Neo4j::Core (neo4j-core gem) and make sure you only commit after each 1000-3000 write operation.

Here is an helper class https://gist.github.com/4516914.

Example of usage

t = TransactionalExec.new(1000) do |data|
   Neo4j::Node.new(data) # or use your model classes (the Neo4j::Rails::Model)
end

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 <https://github.com/andreasronge/neo4j-perf> for examples
Clone this wiki locally