neo4j - Return node if relationship is not present -
i'm trying create query using cypher "find" missing ingredients chef might have, graph set so:
(ingredient_value)-[:is_part_of]->(ingredient) (ingredient) have key/value of name="dye colors". (ingredient_value) have key/value of value="red" , "is part of" (ingredient, name="dye colors").
(chef)-[:has_value]->(ingredient_value)<-[:requires_value]-(recipe)-[:requires_ingredient]->(ingredient) i'm using query ingredients, not actual values, recipe requires, return ingredients chef not have, instead of ingredients each recipe requires. tried
(chef)-[:has_value]->(ingredient_value)<-[:requires_value]-(recipe)-[:requires_ingredient]->(ingredient)<-[:has_ingredient*0..0]-chef but returned nothing.
is can accomplished cypher/neo4j or best handled returning ingredients , sorted through them myself?
bonus: there way use cypher match values chef has values recipe requires. far i've returned partial matches returned chef-[:has_value]->ingredient_value<-[:requires_value]-recipe , aggregating results myself.
update 01/10/2013:
came across in neo4j 2.0 reference:
try not use optional relationships. above all,
don’t use them this:
match a-[r?:loves]->() r null make sure don’t exist.
instead so:
match not (a)-[:loves]->() using cypher checking if relationship doesn't exist:
... match source-[r?:sometype]-target r null return source the ? mark makes relationship optional.
or
in neo4j 2 do:
... optional match source-[r:sometype]-target r null return source now can check non-existing (null) relationship.
Comments
Post a Comment