How to return releshionship type in multilevel query?


(Mirto Busico) #1

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

This:

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

gives correctly

╒═════════╕
│"type(r)"│
╞═════════╡
│"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?


(Stefan Armbruster) #2

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


(Mirto Busico) #3

Thanks a lot Stefan

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

works correctly.