Prev |  | Next

## 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

name | similar_favs
--- | ---
2 rows
`"Sara"` | `2`
`"Derrick"` | `1`

Copyright © 2014 Neo Technology

Prev | Up | Next
| Home |