dbzuk
dbzuk

Reputation: 255

Display intermediary nodes and relationships when finding path between two nodes

I'm trying to return the relationships between nodes where there could be one or two hops between them.

More precisely, below, I'm trying to find links between User userA and a Repository that has a relationship with a Status.

match (u:User{login: "userA"})-[*..2]->(r:Repository)-[HAS_STATUS]->(s:Status) 
return *

The above query works and returns all the results, but does not display the relationship between the User and the Repository if there is an intermediate node.

Here's a screenshot of the results and what I mean visually:

enter image description here

Note that for some reason, where there is a single hop between the User and a Repository, the relationship is shown. It's the two hop relationships that are not displayed.

Upvotes: 0

Views: 87

Answers (1)

Graphileon
Graphileon

Reputation: 5385

Try

match path=(u:User{login: "userA"})-[*..2]->(r:Repository)-[HAS_STATUS]->(s:Status) 
return path

About the “for some reason” : the Neo4j viz has an autocomplete that displays edges between neighbours. Even when these edges are not returned by the query.

Upvotes: 1

Related Questions