
Cypher is a Graph Query Language
movies with an id, year and title and actors with a name.
Actors have an :ACTS_IN relationship to movies, which represents the
role they played, the role relationship has also a role attribute.
START n=node(*) RETURN "Hello Graph with "+count(*)+" Nodes!" as welcome;
START movie=node:node_auto_index(id="603") RETURN movie;
START movie=node:node_auto_index(id="603") RETURN movie.id, movie.title;
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor RETURN actor;
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor RETURN actor.name order by actor.name;
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor RETURN count(*);
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor WHERE actor.name =~ ".*s$" RETURN actor.name ;
START n=node(*) RETURN count(*);
START n=node(*) MATCH n-[r]->() RETURN type(r), count(*);
START n=node(*) MATCH n-[r]->m RETURN n as from, r as `->`, m as to;
CREATE me={name: "Me"} RETURN me; START me=node:node_auto_index(name="Me") RETURN me.name;
START me=node:node_auto_index(name="Me"), movie=node:node_auto_index(id="603")
CREATE me-[:RATED {stars : 5, comment : "I love that movie!"}]->movie;START me=node:node_auto_index(name="Me") MATCH me-[r:RATED]->movie RETURN r.stars, r.comment,movie.title;
CREATE friend={name: "A Friend"} RETURN friend;START me=node:node_auto_index(name="Me"), friend=node:node_auto_index(name="A Friend") CREATE UNIQUE me-[r:FRIEND]->friend RETURN r;
since property
START me=node:node_auto_index(name="Me"), friend=node:node_auto_index(name="A Friend") MATCH me-[r:FRIEND]->friend SET r.since='forever' RETURN r;
START me=node:node_auto_index(name="A Friend") MATCH me-[:FRIEND]-friend-[r:RATED]->movie RETURN movie.title, avg(r.stars) as stars, collect(r.comment) as comments, count(*);
START me=node:node_auto_index(name="Me")
FOREACH (i in range(1,10) :
CREATE friend={name: "Friend "+i}, me-[:FRIEND]->friend);
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor-[:ACTS_IN]->movie RETURN movie.title, count(*) order by count(*) desc;
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor-[:ACTS_IN]->movie RETURN movie.title, collect(actor.name), count(*) as count ORDER BY count desc;
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor-[:ACTS_IN]->movie <-[:ACTS_IN]-colleague RETURN actor.name, collect(distinct colleague.name);
START m=node:node_auto_index(id="603") MATCH m<-[:ACTS_IN]-actor-[:ACTS_IN]->movie <-[:ACTS_IN]-colleague RETURN colleague.name,count(*) ORDER BY count(*) desc LIMIT 10;
START neo=node:node_auto_index(name="Keanu Reeves"), trinity=node:node_auto_index(name="Carrie-Anne Moss") MATCH p = neo-[:ACTS_IN*0..5]-trinity RETURN p, length(p) LIMIT 10;
START neo=node:node_auto_index(name="Keanu Reeves"), trinity=node:node_auto_index(name="Carrie-Anne Moss") MATCH p = neo-[:ACTS_IN*0..5]-trinity RETURN extract(n in nodes(p) : coalesce(n.title?,n.name?)) as `names and titles`, length(p) ORDER BY length(p) LIMIT 10 ;
Try Cypher live on a dataset of your choice
Cypher is a graph query language. Easy on the eyes, while expressive and powerful.
Cypher is a declarative graph query language that allows for expressive and efficient querying and updating of the graph store without having to write traversals through the graph structure in code.
With from Sweden & the Neo4j Community. © 2013 Neo Technology, Inc. Graphs are Everywhere. Terms | Privacy Policy