0
votes

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 ?

1
Do you have different types of relationships between these nodes? Are you using Labels on your relationships? Do you have Indexes set on name property? neo4j.com/docs/stable/query-schema-index.htmlSupamiu
As said, I have an index on :Station(name) Every node in my graph are Station Yes i have 3 different kind of relationship.Stephane Karagulmez
Oh did not see this, my bad, what about the two other questions? :)Supamiu
Sorry mate, was edited my answer :x How can i know if I have labels on my relationships ? not my db and i'm a beginner with neo4j :xStephane Karagulmez
match a-[r]-b return type(r) will return the list of relationship types you actually have. I think you have to use relationship types to avoid getting every relationships when you actually need only one.Supamiu

1 Answers

1
votes

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