Note that there are some explanatory texts on larger screens.

plurals
  1. POReturn node if relationship is not present
    text
    copied!<p>I'm trying to create a query using cypher that will "Find" missing ingredients that a chef might have, My graph is set up like so:</p> <pre><code>(ingredient_value)-[:is_part_of]-&gt;(ingredient) </code></pre> <p><code>(ingredient)</code> would have a key/value of name="dye colors". <code>(ingredient_value)</code> could have a key/value of value="red" and "is part of" the <code>(ingredient, name="dye colors")</code>.</p> <pre><code>(chef)-[:has_value]-&gt;(ingredient_value)&lt;-[:requires_value]-(recipe)-[:requires_ingredient]-&gt;(ingredient) </code></pre> <p>I'm using this query to get all the <code>ingredients</code>, but not their actual values, that a recipe requires, but I would like the return only the <code>ingredients</code> that the chef does not have, instead of all the ingredients each recipe requires. I tried </p> <pre><code>(chef)-[:has_value]-&gt;(ingredient_value)&lt;-[:requires_value]-(recipe)-[:requires_ingredient]-&gt;(ingredient)&lt;-[:has_ingredient*0..0]-chef </code></pre> <p>but this returned nothing. </p> <p>Is this something that can be accomplished by cypher/neo4j or is this something that is best handled by returning all ingredients and sorted through them myself?</p> <p>Bonus: Also is there a way to use cypher to match all values that a chef has to all values that a recipe requires. So far I've only returned all partial matches that are returned by a <code>chef-[:has_value]-&gt;ingredient_value&lt;-[:requires_value]-recipe</code> and aggregating the results myself. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload