Showing results for 
Search instead for 
Did you mean: 

Finding other people who bought the same products

Node Clone

I want to take a name, find a list of products that person bought, find a list of people who bought the same product, and then return a list of other products those people bought, so long as the original customer didn't also buy them.

Here's the query I wanted to do that:

MATCH (c: customer {customer_name: "SOME GUY"})
MATCH (c)-[:madePurchase]->(:transaction)-[:onShelf]->(:shelf)-[:hasName]->(p:product)
MATCH (other:customer {division: c.division})-[:madePurchase]->(:transaction)-[:onShelf]->(:shelf)-[:hasName]->(p:product)
MATCH (other)-[:madePurchase]->(:transaction)-[:onShelf]->(:shelf)-[:hasName]->(rec:product)
WHERE NOT exists ( (c)-[:madePurchase]->(:transaction)-[:onShelf]->(:shelf)-[:hasName]->(rec) )

RETURN rec.common_name, rec.product_name, COUNT(*) AS score ORDER BY score DESC

This query is taken almost directly from a tutorial on this subject.

It's not working for me, and when I began testing out hypotheses something weird happened.

Here's what I get when I try to return all the purchases made by SOME GUY:

When I try to return all the other customers who bought the same products as SOME GUY, I get back the exact same graph:

Note that the two RETURN statements are asking for entirely different customers.

I've been at this for hours, what could possibly be going wrong?


Graph Maven

Please post the link from where you copied the queries. Thanks

Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.