5.7. Find people based on similar favorites

Figure 5.5. Graph

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

Query 

MATCH (me { name: 'Joe' })-[: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 create (_0 {`name`:"Sara"}) create (_1 {`name`:"Cats"}) create (_2 {`name`:"Derrick"}) create (_3 {`name`:"Bikes"}) create (_4 {`name`:"Jill"}) create (_5 {`name`:"Joe"}) create _0-[:`favorite`]->_3 create _0-[:`favorite`]->_1 create _2-[:`favorite`]->_3 create _2-[:`favorite`]->_1 create _4-[:`favorite`]->_3 create _5-[:`favorite`]->_3 create _5-[:`favorite`]->_1 create _5-[:`friend`]->_0 MATCH (me {name: 'Joe'})-[:favorite]->(stuff)<-[:favorite]-(person) WHERE NOT (me)-[:friend]-(person) RETURN person.name, count(stuff) ORDER BY count(stuff) DESC