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.

"numbered" path

pingelsan
Node Clone

Is there a way to acquire the ordnial number of a node in the resultset of an expression like
match (n {name:'xyz'})-[:HAS_FOLLOWUP*]->(m) return n,m
given that :HAS_FOLLOWUP is always a 1-to-1 relationship - and to do it in cypher?

I DO want to do it in cypher because I'm on GRANDstack and I don't want to pass around arrays just to determine one element's position.

Thanks for any input!

Cheers,
Christoph

1 ACCEPTED SOLUTION

Yes, if you add in a path variable for the pattern, you can use the length() of the path as the distance from it:

match path = (n {name:'xyz'})-[:HAS_FOLLOWUP*]->(m) 
return n, m, length(path) as distance

View solution in original post

2 REPLIES 2

Yes, if you add in a path variable for the pattern, you can use the length() of the path as the distance from it:

match path = (n {name:'xyz'})-[:HAS_FOLLOWUP*]->(m) 
return n, m, length(path) as distance

pingelsan
Node Clone

Thanks, that's what I was looking for.