This file contains hidden or 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 (g:Genius) | |
MATCH (art:Artwork) | |
WITH count(art) as art_total, g | |
MATCH (inv:Invention) | |
WITH count(inv) as inv_total, art_total, g | |
RETURN g.name, art_total as artworks, inv_total as inventions |
This file contains hidden or 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
MERGE (sun:Star { name: "Sun", diameterKm: 1391000, sizeXEarth: 109, massXEarth: 333054, order: 0 }) | |
MERGE (me:Planet { name: "Mercury", diameterKm: 4879, sizeXEarth: 0.4, massXEarth: 0.06, order: 1 }) | |
MERGE (v:Planet { name: "Venus", diameterKm: 12104, sizeXEarth: 0.9, massXEarth: 0.82, order: 2 }) | |
MERGE (e:Planet { name: "Earth", diameterKm: 12756, sizeXEarth: 1, massXEarth: 1, mass: "5.972 × 10^24", order: 3 }) | |
MERGE (ma:Planet { name: "Mars", diameterKm: 6792, sizeXEarth: 0.5, massXEarth: 0.11, order: 4 }) | |
MERGE (j:Planet { name: "Jupiter", diameterKm: 142984, sizeXEarth: 11.2, massXEarth: 317.8, order: 5 }) | |
MERGE (s:Planet { name: "Saturn", diameterKm: 120536, sizeXEarth: 9.4, massXEarth: 95.16, order: 6 }) | |
MERGE (u:Planet { name: "Uranus", diameterKm: 51118, sizeXEarth: 4, massXEarth: 14.54, order: 7 }) | |
MERGE (n:Planet { name: "Neptune", diameterKm: 49528, sizeXEarth: 3.9, massXEarth: 17.15, order: 8 }) |
This file contains hidden or 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 (p) | |
WHERE p:Star OR p:Planet | |
WITH min(p.order) as fromN, max(p.order) as toN | |
UNWIND apoc.coll.pairsMin(range(fromN, toN)) as pair | |
MATCH (p1 { order: pair[0] }) | |
WHERE p1:Planet OR p1:Star | |
MATCH (p2:Planet { order: pair[1] }) | |
MERGE (p1)-[:NEXT]->(p2) |
This file contains hidden or 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 (p) | |
WHERE p:Planet OR p:Star | |
WITH toInteger(ceil(p.sizeXEarth * 10)) as size, p | |
UNWIND range(1, size) as chunk | |
MERGE (pc:Chunk { n: chunk })-[:OF]->(p) |
This file contains hidden or 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
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.people AS character | |
RETURN character.name |
This file contains hidden or 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
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.films AS film | |
UNWIND value.people AS character | |
UNWIND value.planets AS planet | |
MERGE (:Film { name: film.title, url: film.url }) | |
MERGE (:Character { name: character.name, url: character.url }) | |
MERGE (:Planet { name: planet.name, url: planet.url }) |
This file contains hidden or 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
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.species AS spec | |
UNWIND value.vehicles AS vehicle | |
UNWIND value.starships AS starship | |
MERGE (:Species { name: spec.name, url: spec.url }) | |
MERGE (:Vehicle { name: vehicle.name, url: vehicle.url }) | |
MERGE (:Starship { name: starship.name, url: starship.url }) |
This file contains hidden or 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
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 |
This file contains hidden or 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
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.films as film | |
UNWIND film.starships as starship_url | |
MATCH (f:Film { url: film.url }) | |
MATCH (s:Starship { url: starship_url }) | |
MERGE (s)-[:APPEARED_IN]->(f); | |
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.films as film |
This file contains hidden or 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
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.people as character | |
UNWIND character.species as species_url | |
MATCH (c:Character { url: character.url }) | |
MATCH (spec:Species { url: species_url }) | |
MERGE (c)-[:OF]->(spec); | |
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.people as character |