I was wondering whether it’s possible to compare two sets of individuals to determine whether one set contains the other using a get query.
To make it a bit more specific:
Suppose I have some recipes that require different ingredients and a pantry with a set of available ingredients. I have modeled the connection between a recipe and its required ingredients as a relationship: (requiring_recipe: $r, required_ingredient: $i) isa requires, where $r and $i are entities of types recipe and ingredient respectively. And the connection between the pantry and the ingredients is modeled as a relationship as well: (containing_pantry: $p, contained_ingredient: $i) isa contains, where $p and $i are entities of types pantry and ingredient respectively. Now I would like to query the data to find out which recipes I could cook with the ingredients that are available in the pantry. I thought that the following query would give me the answer:
match $p isa pantry; $ip isa ingredient; (containing_pantry: $p, contained_ingredient: $ip) isa contains; $r isa recipe; (requiring_recipe: $r, required_ingredient: $ip) isa requires; get $r;
But this query gives too many results, probably because it returns the recipes that require at least one of the ingredients in the pantry, but also require ingredients that are not available. So I was wondering how to query the data such that the query returns only those recipes for which the set of required ingredients is contained within the set of available ingredients.