Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-10-2023 02:58 AM
Hi,
I have the following scenario:
In all cases the returned path should be the one that is coloured. When the middle Service is as in Case 1, then the returned path should only consider the top and bottom level services and not the middle one. Is there any apoc procedure to skip a node in the path? Or could this be achieved with a normal Cypher statement? Thanks in advance!
01-10-2023 05:33 AM - edited 01-10-2023 05:34 AM
I am sorry, I don’t fully understand your scenario. Are you searching for a path with a pattern and you only want paths that match the right three to return and have the left one eliminated from the result?
What do you mean by ‘skip’ the node?
Can you share any cypher code you tried?
01-10-2023 05:36 AM
So I would like to return the four paths but in CASE 1, I would like to return only the top and the bottom service. "Skip" is a property that shows me the node that I should consider to skip (not include in the returned path).
01-10-2023 09:16 AM - edited 01-10-2023 09:20 AM
Sorry, I am still not clear. Do you know the start and end nodes, or are these also found by the query? For example, in the following we specify the start and end node and find the path between them that matches your pattern:
match(s1:Service{id:1})
match(s2:Service{id:2})
match p=(s1)-[:HAS_PARENT*0..999]->(s:Service)-[:HAS_PARENT*0..999]->(s2)
return p
Or, we don't know the specific nodes; only that they are 'Service' nodes. In this case, the query would be more like the following:
match p=(s1:Service)-[:HAS_PARENT*0..999]->(s:Service)-[:HAS_PARENT*0..999]->(s2:Service)
return p
It sounds more like the latter, since you want to only return the start and end nodes for case 1. Is this what you want?
What is it you actually want to return: 1) the entire path, 2) all the nodes along the path, or 3) just the start, middle, and nodes? When you state 'skip' the middle node, what does that mean?
It looks like the discriminating factor that identifies case 1 is that the start, middle, and end nodes all have 'type' equal to 'skip'. Is this true?
Since your pattern has a lower limit of '0' for number of hops in both relationships, you could get a result that consists of just one 'Service' node for the match.
Sorry for all the questions, but it will help me understand what your requirements are.
01-16-2023 02:00 AM
thanks for your reply. The conditions are as following:
Note that the modified path means to return only the path the contains the start and the end node, while skipping or not including the middle node. Then the path would be:
(s:Service)-[:HAS_GRANDPARENT* 0..999]->(s2:Service) ----> where the middle service is not included here. I hope that you understand better now the issue.
All the sessions of the conference are now available online