How to return releshionship type in multilevel query?

Hi all,
I'm trying to extract the relationship types from a query; but it works only for direct relation.


MATCH (n:POC) -[r]- (m) RETURN type(r)

gives correctly

│"SON_OF" │
│"SON_OF" │

But when I try this

MATCH (n:POC) -[r*1..2]- (m) RETURN type(r)

I receive the error

Type mismatch: expected Relationship but was List<Relationship> (line 2, column 13 (offset: 41)) "RETURN type(r)" 

What is the correct syntax to return this list?

Try return [x in r | type(x)]

Thanks a lot Stefan

MATCH (n:POC) -[r*1..2]- (m) RETURN [x in r | type(x)]

works correctly.

1 Like