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

Post on 28-Nov-2014

645 views 2 download

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

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

Pré-requis du jour / RAPPEL

SUPPORT TESTNG IDE

Page de réclame

@fbiville @ogirardot

@LateraIThoughts

mailto:contact@lateral-thoughts.com

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

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

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

Base de données orientée graphe !

Flock DB

Graphe ?

des noeuds des relations

Graphe ?

Base de données graphe ?

Base de données graphe ?

Au programme : BIRGGIT !

Au programme : BIRGGIT !

Le 1er gestionnaire de versions sans contenu !

Au programme : BIRGGIT !

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

● birggit init

● birggit commit

● birggit log

● birggit gc

Exercicestest-driven !

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());

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" ));

Exercice 3

BFS DFS

Exercice 3

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)) { … }

Exercice 4

Pattern matching sur graphe

Exercice 4

Pattern matching sur graphe

Exercice 4

Pattern matching sur graphe - illustration

Exercice 4

Pattern matching sur graphe - illustration

Exercice 4

Pattern matching sur graphe - illustration

Exercice 4

Pattern matching sur graphe - illustration

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

()-->()

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

(A)-->(B)

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

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

Exercice 4

Pattern matching sur graphe - syntaxe

Cypher

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

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

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)

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

Conclusion

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/

Conclusion

Expérimenter

http://console.neo4j.org

Discuter

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

Partager

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

Merci / auf wiedersehen !

@fbiville @ogirardot

@LateraIThoughts

mailto:contact@lateral-thoughts.com