Last active
November 12, 2016 22:12
-
-
Save freeeve/b8ad30f1aacb7cef5c3a806c106b1502 to your computer and use it in GitHub Desktop.
for the data import
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
create constraint ON ( movie:Movie ) ASSERT movie.id IS UNIQUE; | |
create constraint ON ( person:Person ) ASSERT person.id IS UNIQUE; | |
create index ON :Movie(title); | |
create index ON :Person(name); | |
// migrate genres to nodes | |
match (m:Movie) | |
unwind m.genres as genre | |
merge (g:Genre {name:genre}) | |
merge (m)-[:IN_GENRE]->(g); | |
// keanu reeves from 1996 | |
match (p:Person)-[:ACTED_IN]->(m:Movie) | |
where p.name = "Keanu Reeves" | |
and m.released > 1996 | |
return avg(m.avgVote), collect(m.avgVote), stdev(m.avgVote), collect(m.released) |
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
LOAD CSV WITH HEADERS | |
FROM "https://raw.githubusercontent.com/mneedham/graphconnect-training/master/new_movies.csv" | |
AS line | |
merge (m:Movie {id:line.movieId}) | |
on create set | |
m.title=line.title, | |
m.avgVote=line.avgVote, | |
m.released=line.releaseYear, | |
m.genres=split(line.genres, ':') | |
return count(m); | |
LOAD CSV WITH HEADERS | |
FROM "https://raw.githubusercontent.com/mneedham/graphconnect-training/master/people.csv" | |
AS line | |
merge (p:Person {id:line.personId}) | |
on create set | |
p.name = line.name, | |
p.born = toInt(line.birthYear), | |
p.died = toInt(line.deathYear) | |
return count(p); | |
LOAD CSV WITH HEADERS | |
FROM "https://raw.githubusercontent.com/mneedham/graphconnect-training/master/directors.csv" | |
AS line | |
match (p:Person {id:line.personId}) | |
match (m:Movie {id:line.movieId}) | |
merge (p)-[:DIRECTED]->(m) | |
return count(p); | |
LOAD CSV WITH HEADERS | |
FROM "https://raw.githubusercontent.com/mneedham/graphconnect-training/master/actors.csv" | |
AS line | |
match (p:Person {id:line.personId}) | |
match (m:Movie {id:line.movieId}) | |
merge (p)-[r:ACTED_IN]->(m) | |
on create set r.roles = split(line.characters, ':') | |
return count(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment