I am trying to create a request using cypher that will "detect" the missing components that the chef may have. My graph is set up like this:
(ingredient_value)-[:is_part_of]->(ingredient)
(ingredient) will have the key / value name = "dye colors". (ingredient_value) can have a key / value value = "red" and "is part" (ingredient, name="dye colors") .
(chef)-[:has_value]->(ingredient_value)<-[:requires_value]-(recipe)-[:requires_ingredient]->(ingredient)
I use this query to get all ingredients , but not their actual values that are required for the recipe, but I would like to return only the ingredients that the chef does not have, instead of all the ingredients needed for each recipe. I tried
(chef)-[:has_value]->(ingredient_value)<-[:requires_value]-(recipe)-[:requires_ingredient]->(ingredient)<-[:has_ingredient*0..0]-chef
but it didn’t return anything.
Is this something that cypher / neo4j can do, or is it something that is best handled by returning all the ingredients and sorting them yourself?
Bonus: There is also a way to use cypher to match all the values that the cook has for all the values that the recipe requires. So far, I have returned all partial matches returned by chef-[:has_value]->ingredient_value<-[:requires_value]-recipe and aggregating the results myself.
neo4j cypher
Nicholas Jun 08 2018-12-12T00: 00Z
source share