Reputation: 433
I am using neo4j, I have nodes with two properties: name and id. I have an index on id. I have relationships "CALL" with a property: "by_test". This property can take different value (id of any node).
Two nodes can have multiple CALL relationships with different by_test property value.
So let's say I have 1..N nodes linked by the same CALL.by_test property value.
Node1 -> Node2 -> Node3 -> .. -> Node N
How can I get all these nodes?
Do I need to put an Index on the relationship?
Do I have to create dynamic relationship? Instead of CALL.by_test=value, use value has a relationship.
Thanks!
Upvotes: 1
Views: 654
Reputation: 1144
Using Cypher, you could query for that list like this:
START n=node:node_auto_index(name="one")
MATCH p=(n)-[r:CALL*1..]->(m)
WHERE ALL(x in r WHERE x.by_test = 3)
RETURN n,m
In the MATCH
you bind a term r
to the CALL
relationships, which you then use in the WHERE
clause to check the by_test
property of each.
As Michael Hunger noted, the r
is a collection of relationships, so the WHERE
needs to use ALL
to check each of the relationships.
Upvotes: 1