Sunday, February 19, 2012

Neo4J with Scala Play! 2.0 on Heroku (Part 2) :: Neo4J

Neo4J

This post is a continuation of this post, where I've introduced for what is dedicated this suite.
In the current post, we'll talk a bit of Neo4J and why I've considered it as a back end service for storing data in one of my later spikes.

Some works on Graph DB

A graph database is a kind of NoSQL, that stores neither data as KVP nor as Column even nor as Collection of document, but as... Graph.
Ok, ok, it's quite obvious but what to say more, maybe that it's querying is very interesting because it relies on a notion of traversal, that would require joins on joins in classical RDMBS.
The main purpose of such graph storing is high dergeed inter-connected data, as Social data are.

Neo4J

I quickly fall on this product for handling my test domain model that figures the social network use case, where users are connected to users, and participates in groups.
Neo4J is written in Java, where a lot of NoSQL database are C++ based. Moreover, where most of NoSQL databases requires standalone installation to work, Neo4J is able to create Embedded databases running instances (look like the jetty revolution for servlet containers).
Finally, my choice was arrested when I saw its RESTful interface; still in working status but which is promising, with url patterns auto-discovery using the service root response.
Final Finally (I promise), I saw that Neo4J community was huge, that Spatial was already taken into account (GIS has highly inter-connected data, and it'll be probably my next spike). But also, it offers good usage of Lucene as back end indexing provider.

Install It, Start

Quite simple, and I wouldn't expand my self to much on the topic rather than pointing the extractable http://neo4j.org/download.
Drop the extracted folder wherever you want, and set your PATH to target the Neo4J/bin folder where is located the neo4j executable.
When it's done two choices are up to you:

Sanity check...

The server will run listening on your localhost:7474/. Using your browser you'll directly be redirected to the webadmin interface.
Since I can talk further on this web admin, I'll introduce some features I loved.

... WebAdmin (is your friend)

The Neo4J web amin interface offers a way to query your graph very easily through a simple string using tags (like Lucene query string) in order to match nodes, relationships, paths, indexes and so on.
So far so good, and? Ok it presents you the result in an editable table...
Mmmmh exiting... Ok and you can see your graph using their arbor.js based viewing tool. Ha ha!
The other tool I like is the web based console for trying Cypher or Gremlin queries or even to try the HTTP REST interface.

Let's create the project and configure IDEA