Skip to content

Instantly share code, notes, and snippets.

@vladbatushkov
Created May 12, 2019 15:11
Show Gist options
  • Save vladbatushkov/9d2ec2fa8287f8f18680b443380f7451 to your computer and use it in GitHub Desktop.
Save vladbatushkov/9d2ec2fa8287f8f18680b443380f7451 to your computer and use it in GitHub Desktop.
Similar flags.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment