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 (b:Band)-[:OF]->(g:Genre { name: "Rock" }) | |
CALL apoc.load.html("https://last.fm/music/" + replace(b.name, " ", "+") + "/+listeners", { data: "h4.user-list-name a" }) YIELD value | |
UNWIND value.data as n | |
MERGE (p:Person { name: n.text }) | |
MERGE (p)-[:LIKES]->(b) |
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 (vb:Person { name: "vlad batushkov" })-[:LIKES]->(cross_band:Band)<-[:LIKES]-(p:Person)-[:LIKES]->(other_band:Band) | |
WHERE NOT (vb)-[:LIKES]->(other_band) | |
WITH other_band.name as name, count(p) as followers_num | |
RETURN name, followers_num | |
ORDER BY followers_num DESC | |
LIMIT 10 |
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 (red:Color { name: "Red" }) | |
MERGE (white:Color { name: "White" }) | |
MERGE (blue:Color { name: "Blue" }) | |
MERGE (green:Color { name: "Green" }) | |
MERGE (yellow:Color { name: "Yellow" }) | |
MERGE (black:Color { name: "Black" }) | |
MERGE (f1:Flag { name: "Belarus" }) | |
MERGE (f1)-[:CONTAINS { weight: 60 }]->(red) | |
MERGE (f1)-[:CONTAINS { weight: 30 }]->(green) | |
MERGE (f1)-[:CONTAINS { weight: 10 }]->(white) |
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 (:Flag)-[c1:CONTAINS]->(:Color) | |
WITH sum(c1.weight) as total | |
MATCH (:Flag)-[c2:CONTAINS]->(cl:Color) | |
WITH cl.name as colorName, sum(c2.weight) as colorUsed, total | |
RETURN colorName, colorUsed * 100 / total as percentage | |
ORDER BY percentage DESC | |
LIMIT 10 |
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 (f:Flag), (cl:Color) | |
OPTIONAL MATCH (f)-[c:CONTAINS]->(cl) | |
WITH { item:id(f), weights: collect(coalesce(c.weight, 0)) } as flagData | |
WITH collect(flagData) as data | |
CALL algo.similarity.cosine.stream(data) | |
YIELD item1, item2, count1, count2, similarity | |
RETURN algo.asNode(item1).name AS flag_of, algo.asNode(item2).name AS to_flag_fo, similarity | |
ORDER BY similarity DESC | |
LIMIT 15 |
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
UNWIND range(1950, 2018) as year | |
WITH "https://www.formula1.com/en/results.html/" + year + "/races.html" as url, year | |
CALL apoc.load.html(url, { place: "table.resultsarchive-table tbody tr td:eq(1)", pilot: "table.resultsarchive-table tbody tr td:eq(3)" }) YIELD value | |
WITH collect(value) as data, year | |
WITH { pilots: data[0].pilot, places: data[1].place } as root, year | |
WITH [ x IN range(0, length(root.pilots) - 1) | { pilot: root.pilots[x].text, place: root.places[x].text }] as result, year | |
UNWIND result as item | |
MERGE (y:Year { value: year }) | |
MERGE (p:Pilot { name: item.pilot }) | |
MERGE (c:Country { name: item.place }) |
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 (w:Winner) | |
RETURN w.pilot as pilot, count(w.pilot) as wins | |
ORDER BY wins DESC | |
LIMIT 10 |
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 (w:Winner) | |
RETURN w.pilot as pilot, w.country as race, count(w.pilot) as wins | |
ORDER BY wins DESC | |
LIMIT 10 |
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://www.hollywoodreporter.com/lists/oscar-nominations-2019-complete-list-nominees-1172407/item/best-director-1172474" as url | |
CALL apoc.load.html(url, { movie: "ul.list--unordered__items li div.list-item__body a" }) YIELD value | |
WITH collect(value) as data | |
WITH { movies: data[0].movie } as root | |
WITH [x IN range(0, length(root.movies) - 1) | { title: root.movies[x].text, url: root.movies[x].attributes.href }] as result | |
WITH filter(x IN result WHERE x.title <> "" AND apoc.text.indexOf(x.url, "/review/") > -1) as titled | |
UNWIND titled as item | |
MERGE (m:Movie { title: item.title }) | |
ON CREATE SET m.url = apoc.text.replace(item.url, "edit.", "www.") | |
ON MATCH SET m.url = apoc.text.replace(item.url, "edit.", "www.") |
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 (m:Movie) | |
CALL apoc.load.html(m.url, { reviews: "div.article__body p" }) YIELD value | |
WITH split(value.reviews[0].text + " " + value.reviews[1].text, " ") as keywords, m | |
WITH [x IN keywords | apoc.text.replace(x, "[\\.\\,\\(\\)\\']", "")] as keywords, m | |
SET m.keywords = filter(x IN keywords WHERE size(x) > 4) |