Neo4j: Difference between revisions

From air
Jump to navigation Jump to search
No edit summary
Line 152: Line 152:
* http://neo4j.com/docs/stable/tutorial-traversal-concepts.html
* http://neo4j.com/docs/stable/tutorial-traversal-concepts.html
* http://neo4j.com/docs/stable/tutorial-traversal-java-api.html
* http://neo4j.com/docs/stable/tutorial-traversal-java-api.html

=Mazerunner Neo4J=
https://github.com/neo4j-contrib/neo4j-mazerunner



=Benchmark=
=Benchmark=

Revision as of 07:31, 21 October 2016

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 ?).


Liens

Presentations

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
Neo4J

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

Mazerunner Neo4J

https://github.com/neo4j-contrib/neo4j-mazerunner


Benchmark