LOAD CSV
WITH HEADERS FROM "https://gist.githubusercontent.com/jjinkou2/f882a981212c2e7b8913/raw/55519964000914d859a6d8d8e76b0b8bd135c2a1/3-PlayerCSV" AS csvLine
CREATE (pl:Player { id: toInt(csvLine.id), name: csvLine.name })
LOAD CSV
WITH HEADERS FROM "https://gist.githubusercontent.com/jjinkou2/f882a981212c2e7b8913/raw/f41ecba510181ff771e1d3e3aed0bad2edc57767/CharacterCsv" AS csvLine
CREATE (ch:Charact { id: toInt(csvLine.ID), name: csvLine.Character })
USING PERIODIC COMMIT
LOAD CSV
WITH HEADERS FROM "https://gist.githubusercontent.com/jjinkou2/f882a981212c2e7b8913/raw/accb759c6c6218b14988b6555c7d837519e1001e/4-RatingCsv" AS csvLine
MATCH (pl:Player { name: csvLine.Player }),(ch:Charact { name: csvLine.Character })
CREATE (pl)-[:Rated { rating: toInt(csvLine.Rate)}]->(ch)
test
MATCH (pl1:Player {name:'Brute'})-[r1:Rated]->(ch:Charact)<-[r2:Rated]-(pl2:Player {name:'Gregg'})
RETURN ch.name AS Charact, r1.rating AS `Brute's Rating`, r2.rating AS `Gregg's Rating`
Cosine
MATCH (pl1:Player)
WITH pl1
LIMIT 4
MATCH (pl1)-[x:Rated]->(ch:Charact)<-[y:Rated]-(pl2:Player)
WITH SUM(x.rating * y.rating) AS xyDotProduct,
SQRT(REDUCE(xDot = 0, a IN COLLECT(x.rating) | xDot + a^2)) AS xLength,
SQRT(REDUCE(yDot = 0, b IN COLLECT(y.rating) | yDot + b^2)) AS yLength,
pl1, pl2
CREATE UNIQUE (pl1)-[s:SIMILARITY]-(pl2)
SET s.similarity = xyDotProduct / (xLength * yLength)
MATCH (pl1:Player {name:'Brute'})-[s:SIMILARITY]-(pl2:Player {name:'Gregg'})
RETURN s.similarity AS `Cosine Similarity`