Reputation: 734
I am looking to retrieve all nodes an relationships with respect to outgoing relationships only. That is all nodes 'b' that are connected to 'a' in this manner:
(a)-->(b)
In my situation. I have User nodes that are then connected to another node, lets label it 'work'. And from work node we relate out to many other nodes that may be labeled 'work_friends' or 'work_locations'. This User node may also have other nodes from the user node like school, which in turn would have outgoing nodes labeled 'school_friends' and others.
How would I return all nodes starting from the work node and return his work node and all his work friends and work locations?
What I have been trying.
Match(a:User),(b:Work) WHERE a.UserId = 'xxxx' AND b.Work = 'JobA' Return *
but this ends up only returning the two matched nodes where I want it to return all nodes from the matched work node out.
EDIT 1: So, I guess writing out the problem on here helped me solve my own problem. I have gotten closer to a solution.
Match(a:User),(b:Work)-->(n) Where a.UserId =
'xxxx' AND b.Name = 'CompanyA' Return *
So adding -->(n) in the match returned everything from (a), where (n) is all nodes connected out from (b), that is it returned:
(a)->(b)->(n)
this is close to what I am looking for. I really want to return:
(b)->(n)
and ignore the inbound relationship.
Upvotes: 0
Views: 1898
Reputation: 734
And, I have got my solution. It took me working through this post to solve I guess. I hope it can help out others.
Match(a:User),(b:Work)-->(n) Where a.UserId =
'xxxx' AND b.Name = 'CompanyA' AND (a)-->(b) Return b, n
This returns all nodes list so:
(b)->(n)
where n is all nodes connected out from b.
Upvotes: 2