7.12. Boosting recommendation results

Figure 7.10. Graph


This query finds the recommended friends for the origin that are working at the same place as the origin, or know a person that the origin knows, also, the origin should not already know the target. This recommendation is weighted for the weight of the relationship r2, and boosted with a factor of 2, if there is an activity-property on that relationship

Query. 

START origin=node:node_auto_index(name = "Clark Kent")
MATCH origin-[r1:KNOWS|WORKSAT]-(c)-[r2:KNOWS|WORKSAT]-candidate
WHERE type(r1)=type(r2) AND (NOT (origin-[:KNOWS]-candidate))
RETURN origin.name as origin, candidate.name as candidate,
SUM(ROUND(r2.weight + (COALESCE(r2.activity?, 0) * 2))) as boost
ORDER BY boost desc
LIMIT 10

This returns the recommended friends for the origin nodes and their recommendation score.

Result

origincandidateboost
2 rows

"Clark Kent"

"Perry White"

22

"Clark Kent"

"Anderson Cooper"

4


Try this query live. (0) START origin=node:node_auto_index(name = "Clark Kent") MATCH origin-[r1:KNOWS|WORKSAT]-(c)-[r2:KNOWS|WORKSAT]-candidate WHERE type(r1)=type(r2) AND (NOT (origin-[:KNOWS]-candidate)) RETURN origin.name as origin, candidate.name as candidate, SUM(ROUND(r2.weight + (COALESCE(r2.activity?, 0) * 2))) as boost ORDER BY boost desc limit 10