Brian Underwood edited this page Jan 8, 2017 · 17 revisions

WARNING: Much of the information in this wiki is out of day. We are in the process of moving things to readthedocs



Clone this wiki locally

WARNING: Much of the information in this wiki is out of day. We are in the process of moving things to readthedocs

Neo4j-core v3.0 and v4.0 Code Climate Build Status

A simple Ruby wrapper around the Neo4j graph database that works with the server and embedded Neo4j API. This gem can be used both from JRuby and normal MRI. You may get better performance using it from JRuby and the embedded Neo4j, but it will probably be easier to develop (e.g. faster to run tests) on MRI and neo4j server. This gem is designed to work well together with the neo4j active model compliant gem (see the 3.0 branch).

v3 and v4 are functionally identical and all docs can be used for both versions. The reason for the bump in version number was the substantial overhaul of some public APIs that are used extensively in the Neo4j.rb gem.

For the stable v2.0 version, see the v2.0 branch https://github.com/andreasronge/neo4j-core/tree/v2.x Do not use this gem in production.


You can use this gem in two different ways:

  • embedded - talking directly to the database using the Neo4j Java API (only JRuby)
  • server - talking to the Neo4j Server via HTTP (Both JRuby and MRI)

Embedded or Server Neo4j ?

I suggest you start using the Neo4j server instead of Neo4j embedded because it is easier to use for development. If you later get performance problem (e.g. too many HTTP requests hitting the Neo4j Server) you can try the embedded neo4j with almost no changes in your code base. The embedded neo4j via JRuby also gives you direct access to the Neo4j Java API (e.g. the Neo4j Traversal API) which can be used to do more powerful and efficient traversals.

Usage from Neo4j Server

You need to install the Neo4j server. This can be done by using a Rake task.

Install the gem:

gem install neo4j-core

Create a Rakefile with the following content:

load 'neo4j/rake_tasks/neo4j_server.rake'

Install and start neo4j by typing:

rake neo4j:install[community-2.2.0-M02]
rake neo4j:start

Usage from Neo4j Embedded

The Gemfile contains references to Neo4j Java libraries. Nothing is needed to be installed. The embedded database is only accessible from JRuby (unlike the Neo4j Server). No need to start the server since it is embedded.

Neo4j Embedded HA

Make sure you require the neo4j-embedded gem. Then

require 'neo4j-embedded/embedded_ha_session'

session = Neo4j::Session.open(:ha_db, 'path/to/db')

see EmbeddedHasSession

Neo4j-core API, v3.0

API Documentation

See also Neo4j Docs


Notice there are different license for the neo4j-community, neo4j-advanced and neo4j-enterprise jar gems. Only the neo4j-community gem is by default required.