Neo4j

Neo4J est une implémentation open-source d'un système de bases de données orientées graphe (Graph Databases). Neo4J est écrit en Java 7 (OSGi ?).
 * Langages de requête (LDD/LMD)
 * Cypher, s'inspire de SQL.
 * Guery est un LMD alternatif à Cypher.
 * Transactions ACID (y compris avec l'API REST)
 * Index 1D (temps) et 2D (géoposition: voir Neo4j spatial).
 * API REST et Java
 * extension du serveur par plugin

Liens
 * http://fr.wikipedia.org/wiki/Neo4j
 * http://neo4j.com
 * Refcard Querying Graphs with Neo4j http://refcardz.dzone.com/refcardz/querying-graphs-neo4j
 * "Graph Databases - The Definitive Book on Graph Databases" par Ian Robinson, Jim Webber, and Emil Eifrém (Version électronique gratuite)

Presentations
 * http://www.slideshare.net/neo4j/data-modeling-with-neo4j
 * http://www.slideshare.net/emileifrem/an-intro-to-neo4j-and-some-use-cases-jfokus-2011

=Premiers pas=

Installation
cd neo4j bin/neo4j help bin/neo4j start bin/neo4j status bin/neo4j info
 * 1) --> Usage: neo4j { console | start | start-no-wait | stop | restart | status | info | install | remove }

Naviguez sur http://localhost:7474

Utilisez la console de langage Cypher pour exécuter les requêtes suivantes Cypher

Créez un noeud CREATE (ee:Person { name: "Emil", from: "Sweden", klout: 99 })

Recherchez un noeud MATCH (ee:Person) WHERE ee.name = "Emil" RETURN ee;

Créez des noeuds et des relations entre ces noeuds (ie un graphe). MATCH (ee:Person) WHERE ee.name = "Emil" CREATE (js:Person { name: "Johan", from: "Sweden", learn: "surfing" }), (ir:Person { name: "Ian", from: "England", title: "author" }), (rvb:Person { name: "Rik", from: "Belgium", pet: "Orval" }), (ally:Person { name: "Allison", from: "California", hobby: "surfing" }) CREATE (ee)-[:KNOWS {since: 2001}]->(js), (ee)-[:KNOWS {rating: 5}]->(ir), (js)-[:KNOWS]->(ir), (js)-[:KNOWS]->(rvb), (ir)-[:KNOWS]->(js), (ir)-[:KNOWS]->(ally), (rvb)-[:KNOWS]->(ally)

Recherchez des noeuds en relation (KNOWS) avec le noeud (js.name = "Johan"). MATCH (ee:Person)-[:KNOWS]-(friends) WHERE ee.name = "Emil" RETURN ee, friends

Recherchez des noeuds en relation (KNOWS) avec le noeud (js.name = "Johan"). MATCH (js:Person)-[:KNOWS]--[:KNOWS]-(surfer) WHERE js.name = "Johan" AND surfer.hobby = "surfing" RETURN DISTINCT surfer

Recherchez des noeuds en relation quelquonque avec le noeud (ee). MATCH (ee:Person)-[:KNOWS]-(pers) WHERE ee.name = "Emil" RETURN ee, pers

Créez un noeud (éloigné) CREATE (james:Person { name: "James", from: "France", hobby: "surfing" }) CREATE (james)-[:KNOWS {since: 2010}]->(ally)

Recherche transitive ??? TODO

Arretez le serveur bin/neo4j stop

Modifiez la configuration more conf/neo4j-server.properties nano conf/neo4j-server.properties

Redémarrez le serveur bin/neo4j start

Requêtes via le Neo4J Shell
TODO

http://neo4j.com/docs/stable/shell.html

./bin/neo4j-shell

mknode --cd
 * 1) Create a node

pwd
 * 1) where are we?

set name "Jon"
 * 1) On the current node, set the key "name" to value "Jon"

start n=node(0) return n;
 * 1) send a cypher query

mkrel -c -d i -t LIKES --np "{'app':'foobar'}"
 * 1) make an incoming relationship of type LIKES, create the end node with the node properties specified.

ls
 * 1) where are we?

cd 1 suite http://neo4j.com/docs/stable/shell-sample-session.html
 * 1) change to the newly created node

Requêtes via l'interface REST
TODO

PUT,POST,GET

Requêtes en Java

 * http://neo4j.com/docs/stable/tutorial-traversal-concepts.html
 * http://neo4j.com/docs/stable/tutorial-traversal-java-api.html

=Benchmark=
 * CSV Loader http://jexp.de/blog/2014/10/load-cvs-with-success/
 * http://jexp.de/blog/2014/03/quickly-create-a-100k-neo4j-graph-data-model-with-cypher-only/