I want to find all path from given node with relationship property(each node has param id
). Relationship RELATED_TO
has property type
.
The logic from 10 to 1(through 3): 10 ->(type: type1) 5 ->(type: type1) 3 ->(type: type1) 1
The logic from 10 to 1(through 2): 10 ->(type: type1) 5 ->(type: type1) 2 ->(type: type2) 1;
Example:
10
type1
Expected output: 10 -> 5 -> 3 -> 1 and 10 -> 5 -> 2
How to write the cypher?
Supposing by rel.type
you mean there is a type
property on your RELATED_TO
relationships and you want to ensure the value is type1
and also assuming that when you mean node:10
it means the node with id 10
, you can do it with the following query :
MATCH path=(n)-[r:RELATED_TO* {type: 'type1'}]->(o)
WHERE id(n) = 10
RETURN path