Consider some everyday examples about books.
What to read?
Through a lovely summer of lounging around you’ve read through a stack of paperbacks. The starting academic season has you in a more serious mood, so you browse through the classics you never actually read in college wondering which is worth catching up on. You can narrow the list, but not decide. Generally, our friends make good recommendations since we tend to associate with similar-minded people. Ask them.“Well, starting with me, go to each of my friends to check whether they liked Infinite Jest, On the Road, or The Right Stuff, then pick the most liked.”Cypher was conceived of as short-hand for answering questions just like that: a place to start, a “path” to traverse, then some values to peek at. The book recommendation could look like this:
START me= nodes:node_auto_index(name="Andreas")Reading carefully through that, you’ll easily be able to decipher the meaning. The basics of reading data with Cypher compose nicely into larger, rich queries. Read even more over in Neo4j’s online manual to learn the details.
MATCH (me)-[:knows]->(friends)-[r:likes]->(books)
WHERE books.title in["Infinite Jest", "On the Road", "The Right Stuff"]
RETURN books.title, count(r)
Changing the story
Somehow, magically, information has to exist before you can ask for it. We like to say that Neo4j is whiteboard friendly — what you draw is what you store. With Cypher, data becomes normal sounding statements, particularly when compared to relational databases. I’ve got fairly nerdy friends, yet none of them declare that they have a foreign key relationship with ISBN 0316066524. They pretty much just say they like “Infinite Jest.”To create data about myself, my friend Heather, a book, our friendship and her appreciation of the book:
CREATE (me {name:"Andreas"}), (heather {name:"Heather Yorkston"}),We could keep track of how much people liked a particular book by adding a star rating, like so:
(jest {title:"Infinite Jest"}),
(me)-[:knows]->(heather), (heather)-[:likes]->(jest)
start heather=nodes:node_auto_index(name='Heather Yorkston')If Heather tells me that she has never even read the book, we can remove the “liked” like this:
match (heather)-[r:likes]->(book) where book.title="Infinite Jest"
SET r.rating=5
start heather=nodes:node_auto_index(name='Heather Yorkston')That’s a small sample of how Cypher performs basic database operations: creating, reading, updating and deleting. There’s much more to delve into. Get comfy, then read up on Cypher in Neo4j’s online manual.
match (heather)-[r:likes]->(book) where book.title="Infinite Jest"
DELETE r
Fine Print
This release of Neo4j includes the following highlights:- Zero-downtime rolling upgrades in HA clusters, for nicer administrative ops
- Streamed responses to REST API requests, for faster remote access
- Bi-directional traversals, branch state and path expanders in the traversal framework, for even faster queries
- Support in the Cypher language for writing graph data and updating auto-indexes, see above 😉
- Support for explicit transactions in neo4j-shell, on the command line and through the web
Upgrading
As an incremental service release, Neo4j 1.8 builds upon the previous 1.6 and 1.7 releases, with full backward compatibility. It does not require any explicit upgrade to persistent stores created using Neo4j 1.6 and 1.7 installations. Please see the deployment section of the manual for more detail, including instructions for upgrading installations running Neo4j versions released before 1.6.Get Neo4j 1.8
Neo4j 1.8 is available for:- immediate download on Neo4j.org
- questions on Stack Overflow tag #neo4j
- discussion on the Neo4j Google Group
- full review during a live webinar next week
- deep learning at GraphConnect on November 5 & 6
Always,
Andreas