0

I am attempting to execute a "shortestPath" cypher query in Neo4j but am encountering a strange difficulty. I should get "2 nodes" as the shortest path, however I get nothing.

MATCH p=shortestPath((charlize:Person)-[:KNOWS]-(bacon:Person)) 
WHERE charlize.name="Charlize Theron" AND bacon.name="Kevin Bacon" 
RETURN length(p); 

I do believe I'm running the latest version of Neo4j. Could this be an issue?

Regards!

InverseFalcon
  • 29,576
  • 4
  • 38
  • 51
Jeh Hayer
  • 13
  • 4
  • Hello and welcome to StackOverflow! Please do not link to code on external sites, but instead try to post small parts of the code that are likely to contain the problem. – Jens Habegger May 19 '18 at 16:05

1 Answers1

0

The problem is you haven't specified a variable-length path. [:KNOWS] means that you are looking for a pattern where there is a single :KNOWS relationships between the two nodes, and there isn't one.

You want to use [:KNOWS*] here. Here's the documentation for variable length path matching for reference.

InverseFalcon
  • 29,576
  • 4
  • 38
  • 51