Neo4j: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
Naviguez sur http://localhost:7474 |
Naviguez sur http://localhost:7474 |
||
Utilisez la console de langage Cypher pour exécuter les requêtes suivantes Cypher |
|||
Créez un noeud |
|||
<pre> |
|||
CREATE (ee:Person { name: "Emil", from: "Sweden", klout: 99 }) |
|||
</pre> |
|||
Recherchez un noeud |
|||
<pre> |
|||
MATCH (ee:Person) WHERE ee.name = "Emil" RETURN ee; |
|||
</pre> |
|||
Créez des noeuds et des relations entre ces noeuds (ie un graphe). |
|||
<pre> |
|||
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) |
|||
</pre> |
|||
Recherchez des noeuds en relation (KNOWS) avec le noeud (js.name = "Johan"). |
|||
<pre> |
|||
MATCH (ee:Person)-[:KNOWS]-(friends) |
|||
WHERE ee.name = "Emil" RETURN ee, friends |
|||
</pre> |
|||
Recherchez des noeuds en relation (KNOWS) avec le noeud (js.name = "Johan"). |
|||
<pre> |
|||
MATCH (js:Person)-[:KNOWS]-()-[:KNOWS]-(surfer) |
|||
WHERE js.name = "Johan" AND surfer.hobby = "surfing" |
|||
RETURN DISTINCT surfer |
|||
</pre> |
|||
Recherchez des noeuds en relation quelquonque avec le noeud (ee). |
|||
<pre> |
|||
MATCH (ee:Person)-[:KNOWS]-(pers) |
|||
WHERE ee.name = "Emil" RETURN ee, pers |
|||
</pre> |
|||
Créez un noeud (éloigné) |
|||
<pre> |
|||
CREATE (james:Person { name: "James", from: "France", hobby: "surfing" }) |
|||
CREATE (james)-[:KNOWS {since: 2010}]->(ally) |
|||
</pre> |
|||
Recherche transitive ??? |
|||
<pre> |
|||
TODO |
|||
</pre> |
|||
Line 37: | Line 94: | ||
bin/neo4j start |
bin/neo4j start |
||
</pre> |
</pre> |
||
==Requêtes via l'interface REST== |
|||
PUT,POST,GET |
Revision as of 04:47, 7 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.
- 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)
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 l'interface REST
PUT,POST,GET