cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to get shortestPath by Node name

ta-oka
Node Link

Hi,

I'm start to learning about neo4j.(4.2.1 enterprise)
I want to know why this syntax dose not working.

MATCH (from:Point {name:"10000148386"}), (to:Point{name:"10000089111"}), path=((from)-[*..20]->(to))
RETURN from, to, path

I would like to search shortest path Point to Point by name.
but avobe syntax does not work(no changes no records)

I have tried below syntax. That's working.(ID 15231 is 10000148386, ID 7314 is 10000089111)

MATCH (from:Point),(to:Point), p = shortestPath((from)-[*..20]-(to)) WHERE id(from) = 15231 AND id(to) = 7314 RETURN p

If you have any idea please let me know.

2 REPLIES 2

Hello,

On a similar graph I have, both queries work - and there's no reason why this shouldn't work.

So, the only explanation I have is : are you certain that your :Point nodes have a property name which is of type string ?
As your name property is made only of numbers, maybe you set the property as an Integer instead of as a String.
Try the same query without the quotes on the name filter ?

By the way, my advice would be to write the query this way (it's more compact, and you prevent a match on a cartesian product :

MATCH path=shortestPath((from:Point {name:10000148386})-[*..20]->(to:Place{name:10000089111}))
RETURN path

Note : See how I filter the property as Integer here instead of String

ta-oka
Node Link

Hello marius-san,
Thank you four your advice.

I imported Point name as strings.so i will try to import as integer.
and thanks for improve my syntax!