Database Reference
In-Depth Information
Chapter 6. Cypher: Neo4j query language
This chapter covers
• Explaining Cypher
• Executing Cypher queries
• Writing read-only Cypher queries
• Manipulating graph data using Cypher
In previous chapters we used the Neo4j Core Java API to manipulate and query graph data.
This obviously required some Java skills to write and understand the implemented code. In
addition,asthecomplexityofthequeriesincreased,thecodegrewinbothsizeandcomplex-
ity,makingitdifficulttounderstandinsomecases.Thisiswhereaquerylanguagecomesin
handy,allowingyoutoqueryandmanipulategraphsusingthepowerofexpressivelanguage
structures that are also simple to read.
Neo4j'squerylanguageiscalledCypher.Inthischapterwe'regoingtoexplainthenatureof
Cypher, demonstrate its basic syntax for graph operations, and cover some of the advanced
features that can be useful in day-to-day development and maintenance of Neo4j databases.
6.1. Introduction to Cypher
Cypherisadeclarativequerylanguageforgraphsthatusesgraphpattern-matchingasamain
mechanism for graph data selection (for both read-only and mutating operations). The de-
clarative pattern-matching nature of Cypher means that you can query the graph by describ-
ing what you need to get from it.
To explain how Cypher works, let's take a look at Cypher in action.
6.1.1. Cypher primer
Figure 6.1 shows a simple graph representing a social network.
Search WWH ::




Custom Search