Prasad
Prasad

Reputation: 53

List relation name from n path cypher query

I have country to district nodes

       [:relation]          [:relation]           [:relation]

    A----country---------B-----state---------C-----district-------D

(name=India)        (name=Delhi)         (name=xyz)           (name=abc)

I want to get relation name between each nodes

country state district....

I tried this query i want to traverse 1 to 6 nodes

match p=(n:test10{name:"india"})-[relations:has*1..6]->(m:test10) 
return distinct m.parameter as parameter,m.name as name,
       filter(r IN relations WHERE r.relation <> 'none');

but am not getting correct result kindly help me on the same

Upvotes: 1

Views: 44

Answers (2)

cybersam
cybersam

Reputation: 67044

Your Cypher should work if all the nodes you care about have the test10 label, all the relationships you care about have the has type, and all those relationships store the name value using the relation property.

Upvotes: 0

Luanne
Luanne

Reputation: 19373

You can use extract :

extract(rel in relations | type(rel))

Upvotes: 1

Related Questions