Neo4j Cypher query language

What is Cypher?

Video Thumbnail

Overview

Visual, intuitive, and powerful graph data query language

Cypher’s easy-to-learn pattern constructs make it accessible for developers, data scientists, and those with limited query language experience. Users can simply express what data to retrieve while the underlying engine completes the task – eliminating the need for technical implementation knowledge.

Neo4j and Cypher under the hood

Cypher is an expressive language with advanced graph patterns and collection support. Under the hood, the cypher processing pipeline first parses the query if not in cache, then goes through semantic verification and rewriting of the AST, followed by finding the cheapest execution plan (logical and physical) for all the operations using available planners, all the way to query execution.

Run your own Cypher query right now

Following is an example that demonstrates how easy it is to use Cypher using two simple datasets, TMDB (Movies) and Northwind (Retail). (You can also install these datasets directly into your Neo4j database by running :play movies and :play northwind in the Neo4j Browser and execute the load statements.) This example also shows how much easier it is to use Cypher compared to SQL.

Cypher

MATCH path =
   (p:Product {productName:'Pavlova'})-[:PART_OF*]->(root:Category)
RETURN path

Find the shortest connection between two entities, here the “Bacon-Path.”

Cypher

MATCH (bacon:Person {name:'Kevin Bacon'})
MATCH path = shortestPath(
      (:Person {name:'Meg Ryan'})-[:ACTED_IN*..10]-(bacon))
RETURN path, length(path);

Learn more about these features or run :play cypher-vs-sql in the Neo4j Browser.