I have a flow data starting from Vendor to Customer but in between there are couple of nodes of same type and label.
I am attaching you the query for reference please let me know if i can get any suggestions for optimizing the query .
Reviewing the code, it seems your goal is to get all the paths involved in this workflow. I think the following query achieves the same result. The end result is a list of all the paths returned as rows.
match p=(v:Vendor)-->(m:MatPlant)-->(d:MatPlant)-->(c:MatPlant)-[*0..10]->(u:Customer) where d.matl_typ in ['SEMI FINISHED GOODS','FINISHED GOODS'] and m.matl_typ in ['RAW/PKG MATERIALS','SEMI FINISHED GOODS','FINISHED GOODS'] and u.node_id in ["BBN|0010200001"] and v.node_id in ["US1|0185227002"] and c.node_id in ['US1|000000000048883001|US331'] and m.node_id in ['US1|000000000000000927|US33'] and d.node_id in ['US1|000000000008889607|US33'] and c.matl_typ = 'FINISHED GOODS' optional match k=(d)-[r:MfgMatPlant_To_WorkCenter]->(wc:WorkCenter) optional match l=(c)-[r:MfgMatPlant_To_WorkCenter]->(wc:WorkCenter) with collect(p) + collect(k) + collect(l) as paths unwind paths as path return distinct path as result
Is this what you were looking for?
Hi @glilienfield Sorry for the late reply
Yes we have a single label MatPlant in NEo4j but we have a property of matplant named material type which contains 3 types RAW,SEMI,FINI(BY which we are understand what material type it is ).Which we will be getting these nodesid from Java service so Right now i am defining a single matplant in the flow for each type we have .But I want a way where there will be a dynamic query and less matplant i mention in the flow
How do you want it generalized? Right now you explicitly state you want a path the originates from specific vendors then traverses through three MatPlant nodes, with specific node_id's and matl_typ. This is a very specific requirement. Do you want a variable number of MatPlant nodes instead? If so, what constraints do we put on them, node_id and/or matl_typ? We can do that if we can apply these constraints to all the MatPlant nodes along the path. It will be challenging if we have to specify the constraints by the order of the MatPlant nodes, since there are a variable number of them.
I can try to help if you can explain in more detail the generalization you are looking for.
As an example, you could have the following match pattern. This would look for paths that have one or more MatPlant nodes connected. What constraints do you want on the MatPlant nodes?