Cypher is a declarative query language recently added to the Neo4j graph database. In this talk we explain the motivations for creating this language, describe its current features and design, and dive a little into its implementation. Finally, we discuss the future direction of how we expect the language to evolve.
16. Design Decisions
ASCII-art patterns
A B
Wednesday, February 8, 2012
17. Design Decisions
ASCII-art patterns
A B
(A) --> (B)
Wednesday, February 8, 2012
18. Design Decisions
ASCII-art patterns
LOVES
A B
Wednesday, February 8, 2012
19. Design Decisions
ASCII-art patterns
LOVES
A B
A -[:LOVES]-> B
Wednesday, February 8, 2012
20. Design Decisions
ASCII-art patterns
A B C
Wednesday, February 8, 2012
21. Design Decisions
ASCII-art patterns
A B C
A --> B --> C
Wednesday, February 8, 2012
22. Design Decisions
ASCII-art patterns
A
B C
Wednesday, February 8, 2012
23. Design Decisions
ASCII-art patterns
A
B C
A --> B --> C, A --> C
Wednesday, February 8, 2012
24. Design Decisions
ASCII-art patterns
A
B C
A --> B --> C, A --> C
A --> B --> C <-- A
Wednesday, February 8, 2012
25. Design Decisions
Variable length paths
A B
A B
A B
...
Wednesday, February 8, 2012
26. Design Decisions
Variable length paths
A B
A B
A B
...
A -[*]-> B
Wednesday, February 8, 2012
27. Design Decisions
Optional relationships
A B
Wednesday, February 8, 2012
28. Design Decisions
Optional relationships
A B
A -[?]-> B
Wednesday, February 8, 2012
29. Design Decisions
Closures
start london = node(1), moscow = node(2)
match path = london -[*]-> moscow
where all(city in nodes(path) where city.capital = true)
Wednesday, February 8, 2012
30. Design Decisions
Parsed, not an internal DSL
Execution Semantics Serialisation
Type System Portability
Wednesday, February 8, 2012
31. Design Decisions
Familiar for SQL users
select
start
from
match
where
where
group by
return
order by
Wednesday, February 8, 2012
33. Implementation
Execution Plan
start n=node(0)
return n
Parameters()
Nodes(n)
Extract([n])
ColumnFilter([n])
Wednesday, February 8, 2012
34. Implementation
Execution Plan
start n=node(0)
match n-[*]-> b
return n.name, n, count(*)
order by n.age
Parameters()
Nodes(n)
PatternMatch(n-[*]->b)
Extract([n.name, n])
EagerAggregation( keys: [n.name, n], aggregates: [count(*)])
Extract([n.age])
Sort(n.age ASC)
ColumnFilter([n.name,n,count(*)])
Wednesday, February 8, 2012
35. Implementation
Execution Plan
start n=node(0)
match n-[*]-> b
return n.name, n, count(*)
order by n.name
Parameters()
Nodes(n)
PatternMatch(n-[*]->b)
Extract([n.name, n])
Sort(n.name ASC,n ASC)
EagerAggregation( keys: [n.name, n], aggregates: [count(*)])
ColumnFilter([n.name,n,count(*)])
Wednesday, February 8, 2012
36. Thanks for Listening!
Questions?
Andrés Taylor andres.taylor@neotechnology.com @andres_taylor
Alistair Jones alistair.jones@neotechnology.com @apcj
Wednesday, February 8, 2012