Book Image

Learning Neo4j

By : Rik Van Bruggen
Book Image

Learning Neo4j

By: Rik Van Bruggen

Overview of this book

Table of Contents (18 chapters)
Learning Neo4j
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Where to Find More Information Related to Neo4j
Index

Specific query examples for recommendations


In this example dataset, we are going to explore a couple of interesting queries that would allow us—with the information that is available to us—to construct interesting recommendations for our hypothetical users. We will do so along different axes:

  • Product purchases

  • Brand loyalty

  • Social and/or family ties

Let's start with the first and work our way through.

Recommendations based on product purchases

Let's build this thing from the ground up. The first query we want to write is based on past purchasing behavior. We would like to find people that already share a couple of products that they have purchased in the past, but that also explicitly do not share a number of other products. In our data model, this Cypher query would go something like this:

match (p1:Person)-[:BOUGHT]->(prod1:Product)<-[:BOUGHT]-(p2:Person)-[:BOUGHT]->(prod2:Product)
where not(p1-[:BOUGHT]->prod2)
return p1.name as FirstPerson, p2.name as SecondPerson, prod1.name as...