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)
- 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 # --> Usage: neo4j { console | start | start-no-wait | stop | restart | status | info | install | remove } bin/neo4j start bin/neo4j status bin/neo4j info
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 # Create a node mknode --cd # where are we? pwd # On the current node, set the key "name" to value "Jon" set name "Jon" # send a cypher query start n=node(0) return n; # make an incoming relationship of type LIKES, create the end node with the node properties specified. mkrel -c -d i -t LIKES --np "{'app':'foobar'}" # where are we? ls # change to the newly created node cd 1
suite http://neo4j.com/docs/stable/shell-sample-session.html
Requêtes via l'interface REST
TODO
PUT,POST,GET
Requêtes via Guery
Requêtes en Java
- http://neo4j.com/docs/stable/tutorial-traversal-concepts.html
- http://neo4j.com/docs/stable/tutorial-traversal-java-api.html
Mazerunner Neo4J
https://github.com/neo4j-contrib/neo4j-mazerunner
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/