A Holiday Gift for Graphistas: The Neo4j 3.0 Milestone 2 Release

Learn about the New Features Now Available in the Neo4j 3.0 Milestone 2 ReleaseHappy holidays, graphistas! We’re pleased to give you a freshly packaged milestone release, Neo4j 3.0.0-M02, just in time for tinkering over the holiday weekend.

Disclaimer: Milestone releases like this one are for development and experimentation only as not all features are in their finalized form. Click here if you’re looking for the most fully stable version of Neo4j (2.3.1).

This release features refinements to the Bolt driver API, as well as a smattering of fixes, improvements and small additions. Let’s dive deeper into the introduction of Bolt by looking more closely at an expanded (yet focused) example.

We’ve created a humble GitHub project which you can grab to follow along and try out the running example. You’ll also need a running Neo4j database, so download Neo4j 3.0.0-M02 (which has the compatible version of Bolt). For copy-and-paste convenience, there’s a gist with the individual Cypher queries.

The Reindeer Graph, with Bolt

The Reindeer Graph models a team of reindeer, arranged in pairs except for the lead, all pulling a sleigh. Upon initial creation, the graph looks like this:

A Graph of Santa's Sleigh and Reindeer in Neo4j

How do we create that in Java code using Bolt? Let’s walk through the main() method of RunReindeerGraph.java.

First, we create a Driver with a bolt://localhost URL to connect using Bolt to Neo4j running on localhost. All interactions are session based, providing a context for sequenced transactional operations, so the next step is to create a Session.

RunReindeerGraph.java line 61-62:

Driver driver = GraphDatabase.driver( "bolt://localhost" );
Session boltSession = driver.session();

Now we’re ready to initialize the graph. We’ll use the boltSession.run() to submit a Cypher create query which we’ve saved into a String variable called CREATE_REINDEER_GRAPH.

RunReindeerGraph.java line 68:


Excellent. If you switch to the Neo4j Browser, you’ll be able to query for the Reindeer to see that they’ve arrived.

To exercise the graph, we’ll run a Cypher query which examines each pair of reindeer in the team, summing their individual strengths to find the strongest pair. We’ll use boltSession.run() again but capture the return value, which is a ResultCursor.

Results are a stream of records. A cursor is a mechanism for moving through the stream. Initially, the cursor “points” to nothing, so we ask it to advance to the next record using single(), which will only return true if there is just one record available.

We then pull some values from the record, expecting value(0) and value(1) to be Nodes, the client-side representation of a Neo4j graph nodes for two Reindeer.

RunReindeerGraph.java line 73-82:

ResultCursor resultCursor = boltSession.run(FIND_STRONGEST_PAIR);

if (resultCursor.single()) {
    Node deer1 = resultCursor.value(0).asNode();
    Node deer2 = resultCursor.value(1).asNode();
    System.out.printf("Strongest pair: %s + %s = %d\n",
                    deer1.value("strength").asInt() +

This reveals that Donner and Blitzen are the strongest duo on the team. Congrats caribou!

Let’s add a new reindeer named “Bolt” to the team, paired up with Rudolf. That’s just another simple boltSession.run() with another Cypher query.

RunReindeerGraph.java line 85:


With Bolt in the mix we re-check the strongest pair of reindeer, same as before. As you might guess there’s a new top pair – Rudolf and Bolt. 🙂

Notable Changes

For this release, some notable changes include:
    • Upgrade to Lucene 5, with support for upgrading databases with older Lucene versions – #5861
    • Bolt TCP, TLS, WebSocket and Secure WebSocket now all run over the same port – #6020
    • More details are available in the 3.0 Changelog

Cheers to All!

Thanks to your continued feedback about Neo4j, we’ve been able to focus our attention on what’s most important to you.

That feedback manifest itself in performance improvements and in designing APIs like the Java driver. With Neo4j 3.0 Milestone 2, we feel that progress has been great, though we know there are miles to go before we sleep, and we’re looking forward to delivering more graph goodness in the New Year.

Neo4j 3.0 Milestone 2 is available for download today as part of our Early Access Program.

Send your feedback to feedback@neotechnology.com or raise an issue on GitHub. If you have any questions, feel free to ask on our public Discord channel or post in our Google Group.

From all of us at Neo4j, Cheers!

And to sweeten your holidays we invite you to join our Winter GraphGist Challenge, both for some entertainment during the long winter hours and for the big prizes to top your gift stacks (over $2000 worth). Click below to get started.