5.9. Find friends based on similar tagging

Figure 5.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`:"Animals"}) create (_1 {`name`:"Hobby"}) create (_2 {`name`:"Surfing"}) create (_3 {`name`:"Sara"}) create (_4 {`name`:"Cats"}) create (_5 {`name`:"Derrick"}) create (_6 {`name`:"Horses"}) create (_7 {`name`:"Bikes"}) create (_8 {`name`:"Joe"}) create _2-[:`tagged`]->_1 create _3-[:`favorite`]->_6 create _3-[:`favorite`]->_7 create _4-[:`tagged`]->_0 create _5-[:`favorite`]->_7 create _6-[:`tagged`]->_0 create _7-[:`tagged`]->_1 create _8-[:`favorite`]->_2 create _8-[:`favorite`]->_7 create _8-[:`favorite`]->_6 create _8-[:`favorite`]->_4 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