Neo4j 2.0 is coming


House Neo4j of Graph Databases is one of the Great Houses of NOSQL and the principal noble house of The Graph; many lesser houses are sworn to them. In days of old they ruled as Kings of the Graph; since the Aggregate Store Conquest they have been Wardens of the Path. Their seat, San Mateo, is an ancient castle renowned for its sushi. Their sigil is a octopus racing across a field of white, and their words are “Neo4j 2.0 Is Coming,” one of only a few house mottoes to be a warning rather than a boast. Members of the family tend to be lean of build and long of face, with golden hair and blue eyes.

Whoa… sorry, getting carried away there… but Neo4j 2.0 brings with it some great new functionality. Take a look at the following presentation by Andreas Kolleger.

With it come the Cypher MERGE functionality and a Transactional REST Endpoint starting with Milestone 3, as well as Node Labels and Schema Indexes since the first release.

I wanted to play with the new functionality and see what kind of niceties it affords us. I’m using a sample dataset related to the Movie Industry (Movies, Actors, Directors, etc.) that looks like:

CREATE (TheMatrix {title:'The Matrix', released:1999, tagline:'Welcome to the Real World'})
CREATE (Keanu {name:'Keanu Reeves', born:1964})
CREATE (Carrie {name:'Carrie-Anne Moss', born:1967})
CREATE (Laurence {name:'Laurence Fishburne', born:1961})
CREATE (Hugo {name:'Hugo Weaving', born:1960})
CREATE (AndyW {name:'Andy Wachowski', born:1967})
CREATE (LanaW {name:'Lana Wachowski', born:1965})
CREATE (JoelS {name:'Joel Silver', born:1952})
  (Keanu)-[:ACTED_IN {roles:['Neo']}]->(TheMatrix),
  (Carrie)-[:ACTED_IN {roles:['Trinity']}]->(TheMatrix),
  (Laurence)-[:ACTED_IN {roles:['Morpheus']}]->(TheMatrix),
  (Hugo)-[:ACTED_IN {roles:['Agent Smith']}]->(TheMatrix),

This data is how you’d create data normally in Neo4j 1.9. To update it to 2.0 and make use of Labels and Indexes, we just need to update it slightly. Looking at our graph, we can see we have nodes that represent Actors, Directors, Movies, Writers, etc. Each one of these also has a primary way of being found in the graph, names for various types of people, and titles for Movies. So we’ll create Indexes on these properties for their individual Labels:

CREATE INDEX ON :Actor(name);
CREATE INDEX ON :Director(name);
CREATE INDEX ON :Writer(name);
CREATE INDEX ON :Producer(name);
CREATE INDEX ON :Movie(title);

Then we’ll MATCH the nodes in the graph that should have those labels, and set them. For example, every node that has a “title” property is a Movie, and every node that has an outgoing “ACTED_IN” relationship is an Actor.

MATCH node
WHERE has(node.title)
SET node:Movie;

MATCH node
WHERE (node)-[:ACTED_IN]->()
SET node:Actor;

Yeah, it’s really that easy. Some folks have asked for a “Migration Tool”, but the reality is that a little Cypher does all the work for us.

One of the new REST Endpoints available to us in Neo4j 2.0 allows us to get a list of all the labels. This has been included in Neography as the “list_labels” method. We can use this Metadata to probe the graph and build an interface that doesn’t require much coding or configuration.

I’m going to combine VisualSearch.js and VivaGraph.js to make this happen.

Here is a sneak peak at what it looks like… a blog post on it is forthcoming.


Tagged , , , , , ,

7 thoughts on “Neo4j 2.0 is coming

  1. Duke Matlock says:

    Once you do these steps, will future ACTED_IN source nodes be automatically labeled as an Actor?

    1) CREATE INDEX ON :Actor(name);
    2) MATCH node
    WHERE (node)-[:ACTED_IN]->()
    SET node:Actor;

  2. YuSiang Chen says:

    Hi maxdemarzi,

    I am very interested in that tool in the slide page 26. What is the name of the tool? It should be a kind of web admin tool, but seems better than original one, either GUI or expression of graphic. Thanks for your reply.

  3. Josh Turmel says:

    This is some pretty awesome stuff, is there an estimated release date for 2.0?

  4. Roy D says:

    is there an estimated release date for 2.0?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: