Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

36
git clone https://github.com/LateralThoughts/hands-on-neo4j.git

description

Initiation à Neo4J v2.0 en une série de 4 exercices guidés. http://www.duchess-france.org/hands-on-neo4j/

Transcript of Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Page 1: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

git clone https://github.com/LateralThoughts/hands-on-neo4j.git

Page 2: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Pré-requis du jour / RAPPEL

SUPPORT TESTNG IDE

Page 3: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Page de réclame

@fbiville @ogirardot

@LateraIThoughts

mailto:[email protected]

Page 4: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Agenda

ConférenceOctobre / http://tinyurl.com/soft-shake-neo4j

FormationNovembre / http://tinyurl.com/humancoders-neo4j

BBL : où tu veux quand tu veux !http://www.brownbaglunch.fr/baggers.html#Florent_Biville

Page 5: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Neo4J : mais qu’est-ce que c’est ?

Base de donnée orientée… (vieux barbus n’est pas une bonne réponse)

Page 6: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013
Page 7: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Base de données orientée graphe !

Flock DB

Page 8: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Graphe ?

des noeuds des relations

Page 9: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Graphe ?

Page 10: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Base de données graphe ?

Page 11: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Base de données graphe ?

Page 12: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Au programme : BIRGGIT !

Page 13: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Au programme : BIRGGIT !

Le 1er gestionnaire de versions sans contenu !

Page 14: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Au programme : BIRGGIT !

Opérations possibles (à la fin de ce hands-on)

● birggit init

● birggit commit

● birggit log

● birggit gc

Page 15: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercicestest-driven !

Page 16: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 1

APIs unitaires : création de noeuds/relations

// création d’un noeud avec label

Node monNoeud = graphDB.createNode(

DynamicLabel.label("SUPER_LABEL")

);

monNoeud.setProperty("hello", "world");

// création d’une relation

Relationship love = monAutreNoeud.createRelationshipTo(

monNoeud,

DynamicRelationshipType.withName("IS_IN_LOVE_WITH")

);

love.setProperty("start", new Date());

Page 17: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 2

Indexation “legacy” // retrieve the index manager

IndexManager index = graphDb.index()

// get or create index for nodes

Index<Node> actors = index.forNodes(“mes_noeuds_cheris”)

// or..

index.forRelationshipd(“mes_relations___”)

// then add :

Node reeves = graphDb.createNode();

reeves.setProperty( "name", "Keanu Reeves" );

actors.add( reeves, "name", reeves.getProperty( "name" ));

Page 18: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 3

BFS DFS

Page 19: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 3

Page 20: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 3

// first the import !

import org.neo4j.kernel.Traversal;

// then the real work, with a simple traversal

Node startNode = …

for( Path position : Traversal.description()

.depthFirst() // or not

.evaluator(Traversal.toDepth(...))

.relationships(...)

.traverse(startNode)) { … }

Page 21: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe

Page 22: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe

Page 23: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - illustration

Page 24: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - illustration

Page 25: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - illustration

Page 26: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - illustration

Page 27: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

()-->()

Page 28: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

(A)-->(B)

Page 29: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

(A)-[:LOVES]->(B)LOVES

Page 30: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

(C)<--(A)-->(B)-->(C)

A-->B-->C,A-->C

Page 31: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Cypher - lecture

START <lookup>

MATCH <pattern>

RETURN <expression>

MATCH (stephan:DEVOXXIAN)-[:IS_FRIEND_WITH]->(friend:DEVOXXIAN),

(friend)-[:HAS_ATTENDED]->(conf:CONFERENCE)

WHERE conf.name = "Devoxx"

RETURN stephan, COLLECT(friend)

Page 32: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Exercice 4

Cypher - écriture

MATCH <expression>

CREATE <node/rel>

RETURN <expression>

MATCH a:Person, b:PersonWHERE a.name = 'Someone' AND b.name = 'Anyone'CREATE a-[rel:HATES]->bRETURN rel

Page 33: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Conclusion

Page 34: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Conclusion

Beaucoup d’autres choses !

● plus de Cypher (avec indexing)

● REST (unmanaged extensions, streaming)

● visualisation

○ auto : http://linkurio.us/, Neoclipse, Gephi

○ custom : d3.js, sigma.js…

● NeoAAS : http://www.graphenedb.com/, Heroku

● divers : backup, batch-import, http://gist.neo4j.org/

Page 35: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Conclusion

Expérimenter

http://console.neo4j.org

Discuter

https://groups.google.com/forum/#!forum/neo4jfr

Partager

http://www.meetup.com/graphdb-france/

Page 36: Hands on Neo4J - Duchess France/Zenexity - 25/09/2013

Merci / auf wiedersehen !

@fbiville @ogirardot

@LateraIThoughts

mailto:[email protected]