Reputation: 19131
I'm new to Neo4J and really struggling on a query. This is not my actual domain, but I'm trying to simplify it down to a similar problem.
Given:
I want:
Conceptually a way to solve this might be:
Of course, a Cypher query will likely look very different from this. Any advice offered is greatly appreciated.
Upvotes: 1
Views: 30
Reputation: 29172
Suppose that there is the following data scheme:
Then the query looks like this:
MATCH (R:Region {name: 'My Region'})-[:contains]->(M:Market)
-[:provides]->(P:Product)
<-[:requires]-(RC:Recipe)
WITH R, RC,
count(DISTINCT P) AS productsCountForRecipeByRegion
MATCH (RC)-[:requires]->(P:Product)
WITH R, RC, productsCountForRecipeByRegion,
count(P) as productsCountForRecipe
WHERE productsCountForRecipeByRegion = productsCountForRecipe
RETURN R, RC
Upvotes: 1