Skip to content

Instantly share code, notes, and snippets.

@vladbatushkov
Last active May 5, 2019 08:33
Show Gist options
  • Save vladbatushkov/29cb36b8860065237751c8706ce2ce53 to your computer and use it in GitHub Desktop.
Save vladbatushkov/29cb36b8860065237751c8706ce2ce53 to your computer and use it in GitHub Desktop.
Connect characters, planets and scecies with films they are appeared in.
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url
CALL apoc.load.json(url) YIELD value
UNWIND value.films as film
UNWIND film.characters as character_url
MATCH (f:Film { url: film.url })
MATCH (c:Character { url: character_url })
MERGE (c)-[:APPEARED_IN]->(f);
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url
CALL apoc.load.json(url) YIELD value
UNWIND value.films as film
UNWIND film.planets as planet_url
MATCH (f:Film { url: film.url })
MATCH (p:Planet { url: planet_url })
MERGE (p)-[:APPEARED_IN]->(f);
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url
CALL apoc.load.json(url) YIELD value
UNWIND value.films as film
UNWIND film.species as species_url
MATCH (f:Film { url: film.url })
MATCH (spec:Species { url: species_url })
MERGE (spec)-[:APPEARED_IN]->(f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment