SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Neo4j Product Overview
Neo4j Product Overview
NOSQL, The Web And The Enterprise
private static enum ExampleRelationshipTypes implements
RelationshipType
{
    EXAMPLE
}




GraphDatabaseService graphDb = new EmbeddedGraphDatabase( DB_PATH );
registerShutdownHook( graphDb );




graphDb.shutdown();
Transaction tx = graphDb.beginTx();
try
{
    Node firstNode = graphDb.createNode();
    firstNode.setProperty( NAME_KEY, "Hello" );
    Node secondNode = graphDb.createNode();
    secondNode.setProperty( NAME_KEY, "World" );
 
    firstNode.createRelationshipTo( secondNode,
        ExampleRelationshipTypes.EXAMPLE );
 
    String greeting = firstNode.getProperty( NAME_KEY ) + " "
        + secondNode.getProperty( NAME_KEY );
    System.out.println( greeting );
    tx.success();
}
finally
{
    tx.finish();
}
private void printFriends( Node person )
{
    Traverser traverser = person.traverse(
        Order.BREADTH_FIRST,   //
        StopEvaluator.END_OF_GRAPH, // Graph
        ReturnableEvaluator.ALL_BUT_START_NODE,
        MyRelationshipTypes.KNOWS, // ”KNOWS”
        Direction.OUTGOING ); //
    for ( Node friend : traverser )
    {   //       Node     ”name”
        System.out.println( friend.getProperty( "name" ) );
    }
}
1


            3


1


    2
private static Traverser findHackers( final Node startNode )
{
    TraversalDescription td = Traversal.description()
            .breadthFirst()
            .relationships( RelTypes.CODED_BY, Direction.OUTGOING )
            .relationships( RelTypes.KNOWS, Direction.OUTGOING )
            .evaluator(
                    Evaluators.returnWhereLastRelationshipTypeIs(
RelTypes.CODED_BY ) );
    return td.traverse( startNode );
}

Traverser traverser = findHackers( getNeoNode() );
int numberOfHackers = 0;
for ( Path hackerPath : traverser )
{
    System.out.println( "At depth " + hackerPath.length() + " => "
                        + hackerPath.endNode()
                                .getProperty( "name" ) );
}
Traverser traverser = person.traverse(
    Order.BREADTH_FIRST,
    StopEvaluator.END_OF_GRAPH,
    ReturnableEvaluator.ALL_BUT_START_NODE,
    MyRelationshipTypes.KNOWS,
    Direction.OUTGOING );
for ( Node friend : traverser ){...}
/*
    1. Begin a transaction.
    2. Operate on the graph.
    3. Mark the transaction as successful (or not).
    4. Finish the transaction.
*/
Transaction tx = graphDb.beginTx();
try
{
       ... // any operation that works with the node space
       tx.success();
}
finally
{
       tx.finish();
}
Graph Databases and Endogenous Indices
                                               name property index




views property index                                                                             gender property index




                                                 name=neo4j
                                                 views=56781

             page_rank=0.023                                         cites
                                       cites

                                                                                             name=tenderlove
                                                                                               gender=male
                                                created
                                                                             created
                             created
                                                     date=2007/10

                 cites
                                                                                       follows

                                                           follows
                         created
                                               name=peterneubauer                         follows
         name=graph_blog                                       follows
           views=1000                                                           follows
                                   created




                                                                                             name=ahzf
                                                    name=twarko
                                                      age=30
GraphDatabaseService graphDb = new
EmbeddedGraphDatabase( "path/to/neo4j-db" );
IndexService index = new LuceneIndexService( graphDb );


Node andy = graphDb.createNode();
Node larry = graphDb.createNode();


andy.setProperty( "name", "Andy Wachowski" );
andy.setProperty( "title", "Director" );
larry.setProperty( "name", "Larry Wachowski" );
larry.setProperty( "title", "Director" );
index.index( andy, "name", andy.getProperty( "name" ) );
index.index( andy, "title", andy.getProperty( "title" ) );
index.index( larry, "name", larry.getProperty( "name" ) );
index.index( larry, "title", larry.getProperty( "title" ) );
                                http://wiki.neo4j.org/content/Indexing_with_IndexService
// Return the andy node.
index.getSingleNode( "name", "Andy Wachowski" );


// Containing only the larry node
for ( Node hit : index.getNodes( "name", "Larry Wachowski" ) )
{
    // do something
}


// Containing both andy and larry
for ( Node hit : index.getNodes( "title", "Director" )
{
    // do something
}
                                http://wiki.neo4j.org/content/Indexing_with_IndexService
IndexService index = // your LuceneFulltextIndexService

index.getNodes( "name", "wachowski" ); // --> andy and larry
index.getNodes( "name", "andy" ); // --> andy
index.getNodes( "name", "Andy" ); // --> andy
index.getNodes( "name", "larry Wachowski" ); // --> larry
index.getNodes( "name", "wachowski larry" ); // --> larry
index.getNodes( "name", "wachow* andy" ); // --> andy and larry
index.getNodes( "name", "Andy" ); // --> andy
index.getNodes( "name", "andy" ); // --> andy
index.getNodes( "name", "wachowski" ); // --> andy and larry
index.getNodes( "name", "+wachow* +larry" ); // --> larry
index.getNodes( "name", "andy AND larry" ); // -->
index.getNodes( "name", "andy OR larry" ); // --> andy and larry
index.getNodes( "name", "Wachowski AND larry" ); // --> larry
                                  http://wiki.neo4j.org/content/Indexing_with_IndexService
of a spatial, 2D-index that is explicitly14 Marko A.within a Peter Neubauer
                                          modeled Rodriguez and                         1                                      2



                                                         In order to demonstrate how a quadtree index can be represented an
patial analysis makes use of advanced                indexing structuresis represents a quadtreeset is diagrammed i
                                                      versed, a toy graph data set presented. This data
                                                      ure 8. The top half of Figure 8                   index (vertices 1-9)
 [4, 17]. Quadtrees partition a two-dimensional plane into
 sed upon the spatial density of the points being indexed.                                             type=quad
ow space is partitioned as the density of points increases                                               bl=[0,0]
                                                                                                      tr=[100,100]

 e index.                                                                                                  1
                                                                                            sub                            sub


                                                                 type=quad                                         type=quad                      type=quad
                                                                   bl=[0,0]     2                          3        bl=[50,25]             4       bl=[50,0]
                                                                 tr=[50,100]                                        tr=[75,50]                   tr=[100,100]
                                                                                            type=quad               type=quad
                                                                                               bl=[0,0]              bl=[50,50]
                                                                                             tr=[50,50]            tr=[100,100]
                                                                 type=quad                                                                        type=quad
                                                                   bl=[0,50]    5                 6        9           7                   8        bl=[50,0]
                                                                 tr=[50,100]                                                                      tr=[100,50]
                                                                                                      type=quad
                                                                     [0,100] 1                         bl=[50,25]                                [100,100]
                                                                                                       tr=[62,37]


                                                                                                                            g          f

                                                                                    a       b
                                                                                                                       e
                                                                                5                              7


                                                                                                          9                                         bl=[25,20]
                                                                                                               d           3       h
                                                                                                  c                                                 tr=[90,45]

artition of a plane. This figure is an adaptation of a public
                                                                                                                                           i
d courtesy of David Eppstein.                          6                                                  2 4                                  8 [100,0]
                                                                        [0,0]

 motivations behind this article is to stress the A quadtree index ofof space that contains points of interest. The in
                                            Fig. 8. importance a
TraversalDescription description = Traversal.description()
    .breadthFirst()
    .relationships(Relationships.PAIRED, Direction.OUTGOING)
    .evaluator(Evaluators.excludeStartPosition());


description.traverse( startNode ); // Retrieves the traverser




start programmer=(3) match (programmer)-[:PAIRED]->(pair) return pair




start programmer=(3) match (programmer)-[:PAIRED]->(pair)
where pair.age > 30 return pair, count(*) order by age
skip 5 limit 10
[InComing/Outgoing relationships]
                             # All nodes that A has outgoing relationships to.
                             > start n=node(3) match (n)-->(x) return x
                             ==> Node[4]{name->"Bossman"}
                             ==> Node[5]{name->"Cesar"}
                             > start n=node(3) match (n)<--(x) return x
                             ==> Node[1]{name->David"}


[Match by relationship type]
# All nodes that are Blocked by A.
> start n=node(3) match (n)-[:BLOCKS]->(x) return x
==> Node[5]{name->"Cesar"}

[Multiple relationships]
# The three nodes in the path.
> start a=node(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c) return a,b,c
==> a: Node[3]{name->"Anders"}
==> b: Node[4]{name->"Bossman"}
==> c: Node[2]{name->"Emil"}
[Shortest path]
# : find the shortest path between two nodes, as long as the path is max 15
relationships long. Inside of the parenthesis you can write


> start d=node(1), e=node(2) match p = shortestPath( d-[*..15]->e ) return p
==> p: (1)--[KNOWS,2]-->(3)--[KNOWS,0]-->(4)--[KNOWS,3]-->(2)
[Count/ Group Count]
> start n=node(2) match (n)-->(x) return n, count(*)
# The start node and the count of related nodes.
==>
n:         Node[2]{name->"A",property->13}
count(*): 3


> start n=node(2) match (n)-[r]->() return type(r), count(*)
# The relationship types and their group count.
==>
TYPE(r):   KNOWS
count(*): 3
[SUM/AVG/MAX/COLLECT]
> start n=node(2,3,4) return sum(n.property)
==> 90
> start n=node(2,3,4) return avg(n.property)
==> 30.0
> start n=node(2,3,4) return max(n.property)
==> 44
> start n=node(2,3,4) return collect(n.property)
==> List(13, 33, 44)
An Introduction to Neo4j
An Introduction to Neo4j
An Introduction to Neo4j
An Introduction to Neo4j
An Introduction to Neo4j
An Introduction to Neo4j
An Introduction to Neo4j
An Introduction to Neo4j
An Introduction to Neo4j

Contenu connexe

Plus de Takahiro Inoue

Treasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC DemoTreasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC DemoTakahiro Inoue
 
トレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティングトレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティングTakahiro Inoue
 
Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界Takahiro Inoue
 
トレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解するトレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解するTakahiro Inoue
 
20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューションTakahiro Inoue
 
トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方Takahiro Inoue
 
オンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータオンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータTakahiro Inoue
 
事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612Takahiro Inoue
 
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)Takahiro Inoue
 
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜Takahiro Inoue
 
Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!Takahiro Inoue
 
Hadoop and the Data Scientist
Hadoop and the Data ScientistHadoop and the Data Scientist
Hadoop and the Data ScientistTakahiro Inoue
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big DataTakahiro Inoue
 
An Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsAn Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsTakahiro Inoue
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to TinkerpopTakahiro Inoue
 
Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)Takahiro Inoue
 
Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)Takahiro Inoue
 
はじめてのGlusterFS
はじめてのGlusterFSはじめてのGlusterFS
はじめてのGlusterFSTakahiro Inoue
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDBTakahiro Inoue
 

Plus de Takahiro Inoue (20)

Treasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC DemoTreasure Data × Wave Analytics EC Demo
Treasure Data × Wave Analytics EC Demo
 
トレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティングトレジャーデータとtableau実現する自動レポーティング
トレジャーデータとtableau実現する自動レポーティング
 
Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界Tableauが魅せる Data Visualization の世界
Tableauが魅せる Data Visualization の世界
 
トレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解するトレジャーデータのバッチクエリとアドホッククエリを理解する
トレジャーデータのバッチクエリとアドホッククエリを理解する
 
20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション20140708 オンラインゲームソリューション
20140708 オンラインゲームソリューション
 
トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方トレジャーデータ流,データ分析の始め方
トレジャーデータ流,データ分析の始め方
 
オンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータオンラインゲームソリューション@トレジャーデータ
オンラインゲームソリューション@トレジャーデータ
 
事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612事例で学ぶトレジャーデータ 20140612
事例で学ぶトレジャーデータ 20140612
 
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)トレジャーデータ株式会社について(for all Data_Enthusiast!!)
トレジャーデータ株式会社について(for all Data_Enthusiast!!)
 
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜この Visualization がすごい2014 〜データ世界を彩るツール6選〜
この Visualization がすごい2014 〜データ世界を彩るツール6選〜
 
Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!Treasure Data Intro for Data Enthusiast!!
Treasure Data Intro for Data Enthusiast!!
 
Hadoop and the Data Scientist
Hadoop and the Data ScientistHadoop and the Data Scientist
Hadoop and the Data Scientist
 
MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
 
An Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB PluginsAn Introduction to Fluent & MongoDB Plugins
An Introduction to Fluent & MongoDB Plugins
 
An Introduction to Tinkerpop
An Introduction to TinkerpopAn Introduction to Tinkerpop
An Introduction to Tinkerpop
 
Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)Large-Scale Graph Processing〜Introduction〜(完全版)
Large-Scale Graph Processing〜Introduction〜(完全版)
 
Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)Large-Scale Graph Processing〜Introduction〜(LT版)
Large-Scale Graph Processing〜Introduction〜(LT版)
 
Advanced MongoDB #1
Advanced MongoDB #1Advanced MongoDB #1
Advanced MongoDB #1
 
はじめてのGlusterFS
はじめてのGlusterFSはじめてのGlusterFS
はじめてのGlusterFS
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDB
 

Dernier

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Dernier (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

An Introduction to Neo4j

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 8. NOSQL, The Web And The Enterprise
  • 9.
  • 10.
  • 11. private static enum ExampleRelationshipTypes implements RelationshipType {     EXAMPLE } GraphDatabaseService graphDb = new EmbeddedGraphDatabase( DB_PATH ); registerShutdownHook( graphDb ); graphDb.shutdown();
  • 12. Transaction tx = graphDb.beginTx(); try {     Node firstNode = graphDb.createNode();     firstNode.setProperty( NAME_KEY, "Hello" );     Node secondNode = graphDb.createNode();     secondNode.setProperty( NAME_KEY, "World" );       firstNode.createRelationshipTo( secondNode,         ExampleRelationshipTypes.EXAMPLE );       String greeting = firstNode.getProperty( NAME_KEY ) + " "         + secondNode.getProperty( NAME_KEY );     System.out.println( greeting );     tx.success(); } finally {     tx.finish(); }
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. private void printFriends( Node person ) {     Traverser traverser = person.traverse(         Order.BREADTH_FIRST, //         StopEvaluator.END_OF_GRAPH, // Graph         ReturnableEvaluator.ALL_BUT_START_NODE,         MyRelationshipTypes.KNOWS, // ”KNOWS”         Direction.OUTGOING ); //     for ( Node friend : traverser )     { // Node ”name”         System.out.println( friend.getProperty( "name" ) );     } }
  • 18. 1 3 1 2
  • 19.
  • 20. private static Traverser findHackers( final Node startNode ) {     TraversalDescription td = Traversal.description()             .breadthFirst()             .relationships( RelTypes.CODED_BY, Direction.OUTGOING )             .relationships( RelTypes.KNOWS, Direction.OUTGOING )             .evaluator(                     Evaluators.returnWhereLastRelationshipTypeIs( RelTypes.CODED_BY ) );     return td.traverse( startNode ); } Traverser traverser = findHackers( getNeoNode() ); int numberOfHackers = 0; for ( Path hackerPath : traverser ) {     System.out.println( "At depth " + hackerPath.length() + " => "                         + hackerPath.endNode()                                 .getProperty( "name" ) ); }
  • 21. Traverser traverser = person.traverse(     Order.BREADTH_FIRST,     StopEvaluator.END_OF_GRAPH,     ReturnableEvaluator.ALL_BUT_START_NODE,     MyRelationshipTypes.KNOWS,     Direction.OUTGOING ); for ( Node friend : traverser ){...}
  • 22. /* 1. Begin a transaction. 2. Operate on the graph. 3. Mark the transaction as successful (or not). 4. Finish the transaction. */ Transaction tx = graphDb.beginTx(); try { ... // any operation that works with the node space tx.success(); } finally { tx.finish(); }
  • 23.
  • 24. Graph Databases and Endogenous Indices name property index views property index gender property index name=neo4j views=56781 page_rank=0.023 cites cites name=tenderlove gender=male created created created date=2007/10 cites follows follows created name=peterneubauer follows name=graph_blog follows views=1000 follows created name=ahzf name=twarko age=30
  • 25. GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "path/to/neo4j-db" ); IndexService index = new LuceneIndexService( graphDb ); Node andy = graphDb.createNode(); Node larry = graphDb.createNode(); andy.setProperty( "name", "Andy Wachowski" ); andy.setProperty( "title", "Director" ); larry.setProperty( "name", "Larry Wachowski" ); larry.setProperty( "title", "Director" ); index.index( andy, "name", andy.getProperty( "name" ) ); index.index( andy, "title", andy.getProperty( "title" ) ); index.index( larry, "name", larry.getProperty( "name" ) ); index.index( larry, "title", larry.getProperty( "title" ) ); http://wiki.neo4j.org/content/Indexing_with_IndexService
  • 26. // Return the andy node. index.getSingleNode( "name", "Andy Wachowski" ); // Containing only the larry node for ( Node hit : index.getNodes( "name", "Larry Wachowski" ) ) { // do something } // Containing both andy and larry for ( Node hit : index.getNodes( "title", "Director" ) { // do something } http://wiki.neo4j.org/content/Indexing_with_IndexService
  • 27. IndexService index = // your LuceneFulltextIndexService index.getNodes( "name", "wachowski" ); // --> andy and larry index.getNodes( "name", "andy" ); // --> andy index.getNodes( "name", "Andy" ); // --> andy index.getNodes( "name", "larry Wachowski" ); // --> larry index.getNodes( "name", "wachowski larry" ); // --> larry index.getNodes( "name", "wachow* andy" ); // --> andy and larry index.getNodes( "name", "Andy" ); // --> andy index.getNodes( "name", "andy" ); // --> andy index.getNodes( "name", "wachowski" ); // --> andy and larry index.getNodes( "name", "+wachow* +larry" ); // --> larry index.getNodes( "name", "andy AND larry" ); // --> index.getNodes( "name", "andy OR larry" ); // --> andy and larry index.getNodes( "name", "Wachowski AND larry" ); // --> larry http://wiki.neo4j.org/content/Indexing_with_IndexService
  • 28. of a spatial, 2D-index that is explicitly14 Marko A.within a Peter Neubauer modeled Rodriguez and 1 2 In order to demonstrate how a quadtree index can be represented an patial analysis makes use of advanced indexing structuresis represents a quadtreeset is diagrammed i versed, a toy graph data set presented. This data ure 8. The top half of Figure 8 index (vertices 1-9) [4, 17]. Quadtrees partition a two-dimensional plane into sed upon the spatial density of the points being indexed. type=quad ow space is partitioned as the density of points increases bl=[0,0] tr=[100,100] e index. 1 sub sub type=quad type=quad type=quad bl=[0,0] 2 3 bl=[50,25] 4 bl=[50,0] tr=[50,100] tr=[75,50] tr=[100,100] type=quad type=quad bl=[0,0] bl=[50,50] tr=[50,50] tr=[100,100] type=quad type=quad bl=[0,50] 5 6 9 7 8 bl=[50,0] tr=[50,100] tr=[100,50] type=quad [0,100] 1 bl=[50,25] [100,100] tr=[62,37] g f a b e 5 7 9 bl=[25,20] d 3 h c tr=[90,45] artition of a plane. This figure is an adaptation of a public i d courtesy of David Eppstein. 6 2 4 8 [100,0] [0,0] motivations behind this article is to stress the A quadtree index ofof space that contains points of interest. The in Fig. 8. importance a
  • 29.
  • 30.
  • 31. TraversalDescription description = Traversal.description() .breadthFirst() .relationships(Relationships.PAIRED, Direction.OUTGOING) .evaluator(Evaluators.excludeStartPosition()); description.traverse( startNode ); // Retrieves the traverser start programmer=(3) match (programmer)-[:PAIRED]->(pair) return pair start programmer=(3) match (programmer)-[:PAIRED]->(pair) where pair.age > 30 return pair, count(*) order by age skip 5 limit 10
  • 32. [InComing/Outgoing relationships] # All nodes that A has outgoing relationships to. > start n=node(3) match (n)-->(x) return x ==> Node[4]{name->"Bossman"} ==> Node[5]{name->"Cesar"} > start n=node(3) match (n)<--(x) return x ==> Node[1]{name->David"} [Match by relationship type] # All nodes that are Blocked by A. > start n=node(3) match (n)-[:BLOCKS]->(x) return x ==> Node[5]{name->"Cesar"} [Multiple relationships] # The three nodes in the path. > start a=node(3) match (a)-[:KNOWS]->(b)-[:KNOWS]->(c) return a,b,c ==> a: Node[3]{name->"Anders"} ==> b: Node[4]{name->"Bossman"} ==> c: Node[2]{name->"Emil"}
  • 33. [Shortest path] # : find the shortest path between two nodes, as long as the path is max 15 relationships long. Inside of the parenthesis you can write > start d=node(1), e=node(2) match p = shortestPath( d-[*..15]->e ) return p ==> p: (1)--[KNOWS,2]-->(3)--[KNOWS,0]-->(4)--[KNOWS,3]-->(2)
  • 34. [Count/ Group Count] > start n=node(2) match (n)-->(x) return n, count(*) # The start node and the count of related nodes. ==> n: Node[2]{name->"A",property->13} count(*): 3 > start n=node(2) match (n)-[r]->() return type(r), count(*) # The relationship types and their group count. ==> TYPE(r): KNOWS count(*): 3
  • 35. [SUM/AVG/MAX/COLLECT] > start n=node(2,3,4) return sum(n.property) ==> 90 > start n=node(2,3,4) return avg(n.property) ==> 30.0 > start n=node(2,3,4) return max(n.property) ==> 44 > start n=node(2,3,4) return collect(n.property) ==> List(13, 33, 44)