How to find all nodes between two nodes in graph database?

I`m using Cypher query language and I need to find nodes between node A and E. (A->B->C->D->E)

Next query returns all nodes including A and E, but i need to exclude them, to have B, C, D nodes. How can I filter my query result?

MATCH p= (A:City{name: 'City1'})-[:LINKED*]->(E:City{name: "City5"}) return nodes(p)

Upvotes: 1

Views: 132

Answers (1)

Kelvin Lawrence
Kelvin Lawrence

Reputation: 14391

There are a number of ways you might do this, but a simple option is to just index into the node list using:

return nodes(p)[1..-1]

Upvotes: 0

Related Questions