What I'm trying to do
Being relatively new to Neo4j, I'm trying to find certain nodes with Cypher in a Neo4j graph database. The nodes should be connected by a chain of relationships of a certain type with further conditions on the relationships:
// Cypher
START self = node(3413)
MATCH (self)<-[rel:is_parent_of*1..100]-(ancestors)
WHERE rel.some_property = 'foo'
RETURN DISTINCT ancestors
What goes wrong
If I drop the depth part *1..100
, the query works, but of course, then allows only one relationship between self
and the ancestors
.
But, if I allow the ancestors
to be several steps away from self
by introducing the depth *1..100
, the query fails:
Error: Expected rel
to be a Map but it was a Collection
I thought, maybe this syntax defines rel
to be is_parent_of*1..100
rather than defining rel
to be a relationship of type is_parent_of
and allowing a larger relationship depth.
So, I've tried to make my intentions clear by using parenthesis: [(rel:is_parent_of)*1..100
. But this causes a syntax error.
I'd appreciate any help to fix this. Thanks!