Skip to content

Instantly share code, notes, and snippets.

@vladbatushkov
Created May 16, 2019 17:35
Show Gist options
  • Save vladbatushkov/1e79522101ab75cd5ff880d181493691 to your computer and use it in GitHub Desktop.
Save vladbatushkov/1e79522101ab75cd5ff880d181493691 to your computer and use it in GitHub Desktop.
Set SHARE relationship
MATCH (m1:Movie), (m2:Movie)
WHERE NOT (m1)-[:SHARE]-(m2) AND id(m1) <> id(m2)
WITH m1, m2, apoc.coll.intersection(m1.keywords, m2.keywords) as sameKeys
WITH m1, m2, sameKeys, size(sameKeys) as total
WHERE total > 3
MERGE (m1)-[:SHARE { keywords: sameKeys }]->(m2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment