Let's say we have this cypher
match (n:Person{pid:322})-[k*1..2]->(s) return k
k
would be a Collection
of all relation originating from a specific node n
in at most 2 hops.
How can I get all Node-Relation-Node
where Relation
is in k
? It's something like match (a)-[b]->(c) foreach b in k return a,b,c
but I know this query is invalid since foreach
keyword in Neo4J can't be used in this case.
Edit:
I think I should add some illustration to make things clearer. Here I use an example from Neo4J documentation:
When I start from Charlie Sheen and using 1..2 range, the query must return (assuming the query ends with return a,b,c
)
a | b | c
Charlie Sheen | ACTED_IN | Wall Street
Charlie Sheen | FATHER | Martin Sheen
Martin Sheen | ACTED_IN | The American President
Martin Sheen | ACTED_IN | Wall Street