Database Reference
In-Depth Information
Let's look at this query:
match (p1:Person)-[:BOUGHT]->(prod1:Product)<-[:BOUGHT]-(p2:Person)-
[:BOUGHT]->(prod2:Product)
with p1,p2,count(prod1) as NrOfSharedProducts, collect(prod1) as
SharedProducts,prod2
where not(p1-[:BOUGHT]->prod2) AND NrOfSharedProducts > 2
return p1.name as FirstPerson, p2.name as SecondPerson, extract(x
in SharedProducts | x.name) as SharedProducts, prod2.name as
RecommendedProduct;
As you can see, the basic query is the same as the previous one but we have added
someiltersforthenumberofsharedproducts.Wealsoworkedwiththecollection
of products ( collect(prod1) )andextractedthenamesoftheseproductsintheinal
result. It looks like what is shown in the following screenshot:
The refined recommendations based on product purchases
So let's now take a look at another type of recommendation, based on brand loyalty.
Recommendations based on brand loyalty
Obviously, we all understand that if we already own a product of a particular brand,
it is likely that we will be more interested in other products that are manufactured
bythatsamebrand.Solet'sindthepeoplethatalreadyhavemorethanoneproduct
of a certain brand and see if we can recommend other products by that brand. Here's
the query example:
match (p:Person)-[b:BOUGHT]->(prod1:Product)-[:MADE_BY]->(br:Brand)<-
[MADE_BY]-(prod2:Product)
with p, br, prod2, count(prod1) as NrOfBrandProducts
where not(p-[:BOUGHT]->prod2) and NrOfBrandProducts > 1
return p.name as Person, br.name as Brand, collect(prod2.name) as
RecommendedProducts
order by Person ASC;
 
Search WWH ::




Custom Search