7.7. Find people based on similar favorites

Figure 7.6. Graph


To find out the possible new friends based on them liking similar things as the asking person, use a query like this:

Query. 

START me=node:node_auto_index(name = "Joe")
MATCH me-[:favorite]->stuff<-[:favorite]-person
WHERE NOT(me-[:friend]-person)
RETURN person.name, count(stuff)
ORDER BY count(stuff) DESC

The list of possible friends ranked by them liking similar stuff that are not yet friends is returned.

Result

person.namecount(stuff)
2 rows

"Derrick"

2

"Jill"

1


Try this query live. (1) {"name":"Sara"} (2) {"name":"Cats"} (3) {"name":"Derrick"} (4) {"name":"Bikes"} (5) {"name":"Jill"} (6) {"name":"Joe"} (1)-[:favorite]->(2) {} (1)-[:favorite]->(4) {} (3)-[:favorite]->(2) {} (3)-[:favorite]->(4) {} (5)-[:favorite]->(4) {} (6)-[:favorite]->(2) {} (6)-[:favorite]->(4) {} (6)-[:friend]->(1) {} START me=node:node_auto_index(name = "Joe") MATCH me-[:favorite]->stuff<-[:favorite]-person WHERE NOT(me-[:friend]-person) RETURN person.name, count(stuff) ORDER BY count(stuff) DESC