Nedox
Nedox

Reputation: 33

Get all children nodes from a parent node neo4j

I'm using neo4j, and I'm trying to look up all children nodes of Sensor Type.

Here is an example of my graph :

Project ---> cluster -----> Sensor

and I want to be placed on a project and find all sensors nodes .

Upvotes: 3

Views: 7478

Answers (1)

Supamiu
Supamiu

Reputation: 8731

You can use a depth relationship parameter if you know how deep you want to get the nodes.

Example to get all Sensor nodes related to project 5 based on your example:

Match (p:Project{project_id:5})-[*2]->(s:Sensor) return s

you can match every sensor connected at any depth by replacing *2 by *.

See neo4j documentation on variable length for more informations.

Upvotes: 8

Related Questions