cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Filters on specific nodes in a loop

Hi,

I need help with respect to filtering specific nodes in loop traversal. I have a sample network as below. Start node will be the node(Label D) and I have to traverse till nodes of label Port. My requirement is to fetch the end nodes based on condition applied on fields of nodes with label-Y.

The condition status='Ready' should be applied on all the nodes with label Y. Based on that the required end nodes should be retrieved- P1 and P2.

I am looking for a query to loop through the edges Edge0, Edge1, Edge2 and Edge3 and apply the filters to fetch P1 and P2.

Thanks in advance.

1 REPLY 1

Try this, modify to your properties and such:

match(d:D{id:0})
match path=(d)-[*]->(p:Port)
with p, [i in nodes(path) where 'Y' in labels(i)] as y_nodes
where all(i in y_nodes where i.status = 'Ready')
return p as port, y_nodes