Stephane Karagulmez
Stephane Karagulmez

Reputation: 177

Neo4j - Performance on path query

I have to found all paths between two nodes. The length of each path has to be beetween 1 and 5 ( 2 and 3 for this exemple ).

So i'm using this query :

profile match p = (a:Station {name : 'X'} ) - [r*2..3] -> (b:Station {name : 'Y'} ) return distinct p

I have an index on :Station(name)

but when I profile this query I have this result :

my query's profile So the problem is neo4j takes every relationship possible for this node B and then filters using the name. Is it a way for just taking the relation which involved this two specific nodes ?

Upvotes: 0

Views: 296

Answers (1)

Christophe Willemsen
Christophe Willemsen

Reputation: 20185

Maybe you might want to use allShortestPaths for that, eg :

PROFILE MATCH p=allShortestPaths((n:Person {name:'Ian Robinson'})-[r*1..5]–(b:Person {name:'Michal Bachman'}))
RETURN p

enter image description here

Upvotes: 1

Related Questions