Neo4j 1.8.M01 Release – Vindeln Vy

Neo4j 1.8.M01 has an eye for expansive views, painting a picture with data and hanging it on the web. In this first milestone release, artful work on the Cypher query language is complemented with live views in the Neo4j documentation.


Lead Cypherologist Andrés Taylor has been cranking out work like Pablo Picasso with an empty museum. He shared some of his thoughts about the new Cypher grammar available in 1.8.M01:

ABK: It seems you can’t get Cypher out of your head fast enough.
AT: Yeah, it’s really like that. My family is tired of listening to me talk over the dinner table about implementation details about Cypher, I just can’t let it go.

ABK: Some of Cypher is SQL inspired, showing your SQL roots, but the new grammar is not like SQL.
AT: At first, I didn’t want any mutation stuff in it whatsoever, it was going to be a read only language. Then, I didn’t know what I wanted, but I did know what I didn’t want. Like with SQL, with all the problems you can have with inserting data.

ABK: What kind of problems?
AT: I think that SQL is a wonderful language when you’re talking about SELECT statements, but when you’re doing data manipulation, it quickly breaks down into an imperative thing. For example a normal problem is the “insert or update”, which doesn’t have any clean solution. Another is working over collections of stuff.

ABK: Ah, so that’s why FOREACH is included now.
AT: Yup.
ABK: And so what was your solution?
AT: Being declarative. By giving our users the tools to express what they want in a declarative way so they don’t have to invent patterns to work around the language. And, it is much, much easier to understand what’s happening, for a reader of a query.

AT: Looking at a problem, a bug yesterday, I needed a graph to work on so I wrote:
CREATE a,b, a-[:x]->b, a-[:y]->b;
Try It
Just two nodes, with two relationships between them, and that was awesome. Actually, the first version of this would have looked to much worse. There has been fine-tuning. There was a meetup, when Aseem came with a lot of suggestions and the community had a lot of discussion about it. This is the result.
Continuing with the example, you can give them values, with a JSON look-alike thingy:
CREATE a={name:"Andres", age:37}, b, a-[:x { foo:"bar" } ]->b, a-[:y]->b
Try It
Then update a property like this:
START n=node(0) SET"Michael";
Try It
Simple deletes are now possible like this:
START n=node(0) DELETE n;
Try It

ABK: What about more complex statements, like operations on a subgraph?
AT: Instead of sub-queries, you can chain parts of statements using WITH, which essentially combines a RETURN and a START. Like this:
START lucy=node(1) MATCH lucy-->movie
WITH lucy, collect(movie.title) AS movies
SET lucy.movies = movies
Try It
To work on that collections of things, there is FOREACH:
START lucy=node(1) MATCH lucy-->movie WITH lucy, collect(movie) AS movies 
FOREACH (movie in movies : SET )
Try It

The one rule that we have, is that in one part of the query you can only read from the graph or write to the graph. In the short forms above, there are two logical parts, a write then a read, with an implied separation. To be explicit, and create longer queries from parts, you use WITH.

ABK: Neat. Well, thanks for all the hard work Andrés. Can’t wait to try it out.
AT: There is more to come, but this feels good.  Enjoy.

Hogwarts Manual of Graphs

Having unleashed the live Graph Console, the obvious next step was to animate the Cypher examples in the Neo4j Manual. Now the same graph code that generates the documentation also creates interactive consoles to allow experimentation. As a living, constantly evolving document, the Neo4j Manual learns new ways to help you learn.

The Console itself is evolving into a nice REPL, currently supporting Cypher and Geoff for initial graph creation, and Cypher for queries. A nice touch is that the visualization now highlights created nodes and relationships. When done, the graph and an initial query can be shared with a click of the share-button.
These shared graph-gists are really handy for tweeting questions, reporting issues on github and discussing graph modeling in the Neo4j Google Group.


Other changes of note included in this release are:
  • an OSGi section has been added to the manual
  • streaming results from the REST API
  • the usual relentless performance improvements and bug fixes
You can read all the details in the CHANGES.TXT

Enjoy the View

The 1.8 development branch is off to a promising start. Get it today and give us feedback about the direction we’re headed. Heroku users, you’ll be able to use 1.8.M01 by provisioning Neo4j like this:

# heroku addons:add neo4j --neo4j-version 1.8.M01

As always, thanks to all of you for your feedback. Join us on the google group for discussions, and ask questions on Stack Overflow with tag neo4j.

The Neo4j Team