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, as the complexity of the queries increased, the code grew in both size and complexity, making it difficult to understand in some cases. This is where a query language comes in handy, allowing you to query and manipulate graphs using the power of expressive language structures that are also simple to read.

Neo4j’s query language is called Cypher. In this chapter we’re going to explain the nature of 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

Cypher is a declarative query language for graphs that uses graph pattern-matching as a main mechanism for graph data selection (for both read-only and mutating operations). The declarative pattern-matching nature of Cypher means that you can query the graph by describing 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.

Figure 6.1. A social network graph to be queried

6.2. Cypher syntax basics

 
 

6.3. Updating your graph with Cypher

 
 

6.4. Advanced Cypher

 
 
 

6.5. Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest