Neo4j: Difference between revisions
No edit summary |
|||
Line 97: | Line 97: | ||
bin/neo4j start |
bin/neo4j start |
||
</pre> |
</pre> |
||
==Requêtes via le Neo4J Shell== |
|||
TODO |
|||
http://neo4j.com/docs/stable/shell.html |
|||
<pre> |
|||
./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 |
|||
</pre> |
|||
suite http://neo4j.com/docs/stable/shell-sample-session.html |
|||
==Requêtes via l'interface REST== |
==Requêtes via l'interface REST== |
||
TODO |
|||
PUT,POST,GET |
PUT,POST,GET |
Revision as of 04:58, 13 November 2014
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 ?). Son langage de requête (LDD/LMD), Cypher, s'inspire de SQL. Guery est un LMD alternatif à Cypher. Index 1D (temps) et 2D (geoposition).
- 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)
Presentation
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