cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Getting last relationship from variable length path

Need little help with Cypher. My Cypher is,

MATCH p=(user)-[r1:roles]->(role1:`Role`)-[:include*1..]->(role2:`Role`)
RETURN collect(tail(relationships(p))), collect(role2)

For a path where include relation is more than 1 level deep, it gives all include relations for that path as array with corresponding role2. Where as I want just the last relationship and the respective node.
Thanks.

1 ACCEPTED SOLUTION

Got the answer

RETURN collect(last(relationships(p))), collect(role2)

Thanks.

View solution in original post

1 REPLY 1

Got the answer

RETURN collect(last(relationships(p))), collect(role2)

Thanks.