SlideShare a Scribd company logo
Exploring the Cypher Query
Language through GraphGists
Luanne Misquitta

@luannem
Our Path
Neo4j Cypher ExamplesGraphGists
What if…
Credit: Shantaram Waingankar
Or
Credit: Luanne M.
Or
Credit: Florent Biville
Or
6
Credit: Luanne M.
All you need is…
According to The Beatles
But that’s not why you’re here
What you really need is… a Graph
What is Neo4j?
• A Graph Database
• A labelled property graph
• Nodes with properties and labels (both optional)
• Directed and named relationships with properties
(optional)
• ACID
• Schema free
• Scalable: Billions of nodes and relationships
• Fast: More than 2 million traversals per second
• Suited for highly connected and complex data
What is Neo4j
name:Neo
name: Agent
Smith
name:
Cypher
name:
Morpheus
name:TrinityLoves
Knows
Knows 

{since: 1999}
Knows
Knows
Crew
Crew
Crew
Crew
MatrixMatrix
Cypher
• Declarative graph query language
• Based on English prose and neat
iconography
• Focuses on 
• What to retrieve from the graph and not how to
retrieve it
• Pattern matching
• Your domain instead of database access
• Humane query language, suitable for
developers and operations professionals
Patterns and pictures
Neo Trinity
Loves
Neo loves Trinity
(Neo)-[:LOVES]->(Trinity)
Cypher
Agent
Smith
Knows
Cypher knows Agent Smith
(Cypher)-[:KNOWS]->(Agent Smith)
Pattern matching
14
MATCH
(me:User {name:’Luanne’})-[f:FRIEND_OF]->(friend)-[:LISTENS_TO]->(artist)!
WHERE NOT (me-[:LISTENS_TO]->(artist) AND f.similarity>0.7!
RETURN artist
Luanne
The
Beatles
F1
Aerosmith
F2
Pink
Floyd
FRIEND_OF
{similarity=0.9}
FRIEND_OF
{similarity=0.4}
LISTENS_TO
LISTENS_TO
LISTENS_TOLISTENS_TO
Example Query Structure
15
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
MATCH
• Allows you to specify patterns that Cypher
will search for in the graph
16
Match
17
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
Where
• Filters the results
• Adds constraints to the pattern described in
MATCH
18
Where
19
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
Return
• Returns results
20
Return
21
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
Order By, Limit
• Sort the output
• Return a subset
22
Order By, Limit
23
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
WITH
• Manipulate the result sequence before it is
passed on to the following query parts. 
• The manipulations can be of the shape and/
or number of entries in the result set.
• Combines queries
24
With
25
MATCH (u:User)-[:LISTENS_TO]->(a:Artist)
!
WHERE a.genre=“Rock”
!
WITH u, a, count(a) as artistCount
!
MATCH (a)-[r:PLAYING_IN]->(city)
!
WHERE r.ticketsAvailable=true
!
RETURN u,a,city.name as cityName
!
ORDER BY cityName LIMIT 5
GraphGists
What’s a Gist?
27
• A simple way to share snippets of code or
data
• Automatically versioned, forkable, usable
from Git
• Nicely rendered and presented
Okay, why?
• How do you share your graph model?
• Whiteboard?
• Document?
• How do you demonstrate queries? 
• Need a live database?
• Modelling is incremental
28
What’s a GraphGist?
29
• An AsciiDoc file with:
• A graph domain model
• Descriptive text and pictures
• Example queries against the model
• Interactive and executable Cypher queries
• A Neo4j console for further exploration
• Nicely rendered and presented
GraphGist demos
• Trek and mountaineering routing

http://gist.neo4j.org/?09520d20fbe707951e1b 

@shantaramw
• Organization learning

http://gist.neo4j.org/?8021754 

@luannem
• Doctor Finder

http://gist.neo4j.org/?8748719

@fbiville
• Bombay Railway Routes 

http://gist.neo4j.org/?8159102

@luannem 30
Resources
32
Neo4j
http://www.neo4j.org/
!
Explore and create your own GraphGist
http://www.neo4j.org/learn/graphgist
!
Online Training
http://www.neo4j.org/learn/online_course
Spreading Graph Love
Exploring cypher with graph gists

More Related Content

Similar to Exploring cypher with graph gists (20)

PDF
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
Athens Big Data
 
PDF
Graph Database Using Neo4J
Harmeet Singh(Taara)
 
PDF
Understanding Graph Databases with Neo4j and Cypher
Ruhaim Izmeth
 
PPTX
Intro to Cypher
Brian Underwood
 
PPTX
Intro to Neo4j - Nicole White
Neo4j
 
PDF
Shutl
Neoworks
 
PPTX
Windy City DB - Recommendation Engine with Neo4j
Max De Marzi
 
PPTX
GraphDatabase.pptx
JeyaVarthini1
 
PPT
Hands on Training – Graph Database with Neo4j
Serendio Inc.
 
PDF
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 
PDF
Building Applications with a Graph Database
Tobias Lindaaker
 
PPTX
Calin Constantinov - Neo4j - Bucharest Big Data Week Meetup - Bucharest 2018
Calin Constantinov
 
PDF
Intro to Cypher
Neo4j
 
PPTX
Graph Database Query Languages
Jay Coskey
 
PPTX
Introduction to graph databases in term of neo4j
Abdullah Hamidi
 
PDF
Introduction to graph databases, Neo4j and Spring Data - English 2015 Edition
Aleksander Stensby
 
PPTX
Neo4j graph database
Prashant Bhargava
 
PDF
Neo4j Graph Data Science Training - June 9 & 10 - Slides #3
Neo4j
 
PDF
Intro to Neo4j 2.0
Peter Neubauer
 
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
Athens Big Data
 
Graph Database Using Neo4J
Harmeet Singh(Taara)
 
Understanding Graph Databases with Neo4j and Cypher
Ruhaim Izmeth
 
Intro to Cypher
Brian Underwood
 
Intro to Neo4j - Nicole White
Neo4j
 
Shutl
Neoworks
 
Windy City DB - Recommendation Engine with Neo4j
Max De Marzi
 
GraphDatabase.pptx
JeyaVarthini1
 
Hands on Training – Graph Database with Neo4j
Serendio Inc.
 
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 
Building Applications with a Graph Database
Tobias Lindaaker
 
Calin Constantinov - Neo4j - Bucharest Big Data Week Meetup - Bucharest 2018
Calin Constantinov
 
Intro to Cypher
Neo4j
 
Graph Database Query Languages
Jay Coskey
 
Introduction to graph databases in term of neo4j
Abdullah Hamidi
 
Introduction to graph databases, Neo4j and Spring Data - English 2015 Edition
Aleksander Stensby
 
Neo4j graph database
Prashant Bhargava
 
Neo4j Graph Data Science Training - June 9 & 10 - Slides #3
Neo4j
 
Intro to Neo4j 2.0
Peter Neubauer
 

Recently uploaded (20)

PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Biography of Daniel Podor.pdf
Daniel Podor
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Ad

Exploring cypher with graph gists