6.7. Find friends based on similar tagging

Figure 6.7. Graph

To find people similar to me based on the taggings of their favorited items, one approach could be:

  • Determine the tags associated with what I favorite.
  • What else is tagged with those tags?
  • Who favorites items tagged with the same tags?
  • Sort the result by how many of the same things these people like.

Query 

MATCH
  (me)-[:favorite]->(myFavorites)-[:tagged]->(tag)<-[:tagged]-(theirFavorites)<-[:favorite]-(people)
WHERE me.name = 'Joe' AND NOT me=people
RETURN people.name AS name, count(*) AS similar_favs
ORDER BY similar_favs DESC

The query returns the list of possible friends ranked by them liking similar stuff that are not yet friends.

Result

namesimilar_favs
2 rows

"Sara"

2

"Derrick"

1

Try this query live create (_0 {`name`:"Joe"}) create (_1 {`name`:"Bikes"}) create (_2 {`name`:"Cats"}) create (_3 {`name`:"Animals"}) create (_4 {`name`:"Horses"}) create (_5 {`name`:"Hobby"}) create (_6 {`name`:"Sara"}) create (_7 {`name`:"Derrick"}) create (_8 {`name`:"Surfing"}) create (_0)-[:`favorite`]->(_8) create (_0)-[:`favorite`]->(_1) create (_0)-[:`favorite`]->(_4) create (_0)-[:`favorite`]->(_2) create (_1)-[:`tagged`]->(_5) create (_2)-[:`tagged`]->(_3) create (_4)-[:`tagged`]->(_3) create (_6)-[:`favorite`]->(_4) create (_6)-[:`favorite`]->(_1) create (_7)-[:`favorite`]->(_1) create (_8)-[:`tagged`]->(_5) MATCH (me)-[:favorite]->(myFavorites)-[:tagged]->(tag)<-[:tagged]-(theirFavorites)<-[:favorite]-(people) WHERE me.name = 'Joe' AND NOT me=people RETURN people.name as name, count(*) as similar_favs ORDER BY similar_favs DESC