O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Recommendations based on social ties

In the next version of our recommendation queries, we will be using the relationships--in this particular dataset, based on family ties between parents and/or siblings--between our users to come up with some useful recommendations for their next purchase.

Let's look at the following query:

match (p:Person)-[b:BOUGHT]->(prod:Product),p<-[r1]-(parent:Person)-[r2]->(sibling:Person) 
where type(r1) in ["MOTHER_OF","FATHER_OF"] and type(r2) in ["MOTHER_OF","FATHER_OF"] 
and not(sibling-[:BOUGHT]->prod) 
return p.name as Person, prod.name as RecommendedProduct, collect(sibling.name) as ForSiblings; 

This would give us the products bought by a specific person, and looks for siblings (who have the same mother or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required