database - Neo4j - understanding cypher querying -


i'm quite new neo4j , cypher. have written following query:

match (tp: tpproduct_version {tpproductcode: "z1115"}) <-[:is_tpbomparent_of]-(pv: product_version) <-[:is_bomparent_of*..]-(parent: product_version) return parent, pv, tp

here result: http://postimg.org/image/ve76qy977/

actually expecting product_versions have [is_tpbomparent_of] relation z1115 plus parents, no matter if have 1 or not.

but instead got these product_versions wich have parents wich don't seem ignored.

i hope can follow thoughts! lot! nice if me out! :)

greetings schakron

so want use optional match.

your query forces neo4j match pattern. if pattern doesn't exist, don't matched data back. in case want product_versions, not ones have parents, ones don't.

so try query instead:

match (tp: tpproduct_version {tpproductcode: "z1115"})<-[:is_tpbomparent_of]-(pv: product_version) optional match (pv)<-[:is_bomparent_of*..]-(parent: product_version) return parent, pv, tp 

this should return tp, , pv objects. try match further pv objects parent objects, , return them if exist. if don't exist, should still pvs don't have parent.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -