Last active
August 29, 2015 14:06
-
-
Save kyktommy/e937d0ee3468ed716d3f to your computer and use it in GitHub Desktop.
Neo4j query examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (b:Book) | |
WHERE ANY ( tag IN b.tags WHERE tag IN ['nosql','neo4j'] ) | |
RETURN b.title,b.tags | |
SKIP 20 | |
ORDER BY b.title DESC | |
LIMIT 20 | |
------------ | |
MATCH (b:Book)<-[r:Votes]-(:User) | |
OPTIONAL MATCH (b) -[p:PublishedBy]-> (c) | |
RETURN | |
CASE p.year % 2 | |
WHEN 0 THEN 'Even' | |
WHEN 1 THEN 'Odd' | |
ELSE 'Unknown' END as parity, | |
AVG(r.score) | |
------------ | |
MATCH (b:Book) <-[r:Votes]- (:User) | |
WITH b, AVG(r.score) as avgScore | |
ORDER BY avgScore DESC | |
LIMIT 1 | |
OPTIONAL MATCH (b) –[p:PublishedBy]-> () | |
RETURN b.title, p.year | |
------------ | |
MATCH p=shortestPath( | |
(a:User {name: "Mary", surname: "Smith"})-[*]- | |
(b:User {name: "Jane", surname: "Jones"}) ) | |
FOREACH (n IN tail(nodes(p)) | | |
CREATE UNIQUE (n)-[:MaybeKnows]->(a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment