Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-13-2023 12:21 AM - edited 01-13-2023 06:18 AM
Hi Everyone,
I'm new to Neo4j and I'm working on poc where there are multiple services that can read and write to each other and modeled with <CAN_READ_FROM(INCOMING):CAN_WRITE_TO(OUTGOING)> directed relationships as shown in the image below. Now I want to query a workflow or chain relationships(paths) between nodes, so that they will return the all the similar paths. I have tried with apoc.path.pathConfig, but I haven't got the desired results(I'm not sure whether I have tried it right). Need suggestions on query, which will return the below paths.
Updated:
A,B,C,D,E are nodes that represent different services which can read and write from other service as shown above.
Workflow is a series of nodes which can read and write from each other. Since the nodes are related to each other there can be multiple paths from each node to the destination based on the relationships mapped.
So, If I query the below multiple relationships or chain relationships between different nodes as below
MATCH (A)-[:CAN_READ_FROM]->(D)-[:CAN_WRITE_TO]->(C)-[:CAN_READ_FROM]->(B)-[:CAN_WRITE_TO]->(C)
Need to get suggestions for other paths as below
A-E-C-B-C
A-B-C-B-C
As, Service E and B can also read from A and write to C
If I query the paths between A-E-C-B-C
Need to get results as below :
A-D-C-B-C
A-B-C-B-C
@glilienfield.
01-13-2023 05:19 AM - edited 01-13-2023 05:19 AM
sorry, I don’t understand. What is a workflow? What do you mean when you state “query the paths between (A-D-C-B-C)”. How do the resulting workflows correspond to the query path?
01-13-2023 06:19 AM - edited 01-13-2023 06:20 AM
Thank you very much for your response. I have update my question. Please let me know, If it is still not clear. Thanks
01-13-2023 11:08 AM
That is better. All of your example workflows are five long. Is this the requirement? I assumed that. I think this should work. It will find all paths of length five where the node as related by the two relationship types. I noticed all your workflows consisted of relationships in the same direction, so the query assumes that too.
MATCH p=(:Service)-[:CAN_WRITE_TO|CAN_READ_FROM*5]->(:Service)
RETURN [i in nodes(p) | i.name] as nodes
Note, cypher will not traverse the same relationships more than once on the same path. This is to avoid infinite loops. As such, your first example where the path traverses from 'B' to 'C' with a 'CAN_WRITE_FROM' relationships will not be in the results. The apoc path methods let you configure if the uniqueness is at the node level or relationship level.
01-14-2023 12:54 AM
Thank you for your response
All the sessions of the conference are now available online