Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-11-2022 09:47 AM
Hi ,
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 .
07-11-2022 01:44 PM
Are the node_id values unique for each node type? Is there a reason you using conditions like the following when the list is a singleton list? Are you being flexible, so that you can added additional elements to any of these lists?
c.node_id in ['US1|000000000048883001|US331']
07-11-2022 10:41 PM
Yes the node ids are unique across the database and yes it is flexible
07-12-2022 08:38 AM
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?
07-12-2022 11:23 PM
Yes. But there are three nodes of matplant in the query flow.I need to know is there any optimized way for it to get the same response in anyother way of querying the cypher in NEo4j?
07-13-2022 04:26 AM
I just refactored your query to simplify it and keep the same functionality.
What are you looking for? Does the query as is give you the results you need? We can try to develop an efficient solution.
07-14-2022 12:59 AM
yes
07-14-2022 09:01 AM
Hi thanks, for the reply
But can I change the functional part in some way or the path I mentioned in the query
07-14-2022 02:38 PM
we can try. Can you describe what changes you want to make? More along the lines of functional changes.
07-15-2022 12:46 AM
Yeah Instead of suing the 3 plants in the flow i need the query in the dynamic way it work for all conditions
07-15-2022 12:47 AM
Yeah instead using 3 matplants in the flow
07-15-2022 02:20 AM
You have three MatPlant nodes now. Do you want more or less? Is it a variable number of them? If so, is there a min and max number?
I don’t understand the change you require. Can you provide an explanation and I be glad to help?
07-18-2022 08:58 AM
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
07-19-2022 04:46 AM - edited 07-19-2022 04:49 AM
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?
match p=(v:Vendor)-[]->(:MatPlant)-[*0..]->(:MatPlant)-[*0..10]->(u:Customer)
07-28-2022 08:29 AM
Hi @glilienfield Could we connect and discuss once i have been trying the same logic for more than 2 weeks Its not really helping me Please provide your email address i can reach you out and discuss
07-28-2022 12:00 PM
done
All the sessions of the conference are now available online