【发布时间】:2024-04-27 16:45:01
【问题描述】:
当我尝试在 Person 节点和 Movie 节点之间执行 shortestPath() 函数时,例如 -
MATCH p=shortestPath((:Person)-[*1..4]->(:Movie))
RETURN length(p)
这失败并出现错误 -
Neo.ClientError.Statement.SyntaxError
shortestPath(...) requires named nodes (line 1, column 9 (offset: 8))
"MATCH p=shortestPath((:Person)-[*1..4]->(:Movie))"
^
要解决这个问题,我必须将节点标签分配给变量,就像这样 -
MATCH pt=shortestPath((p:Person)-[*1..4]->(m:Movie))
RETURN length(pt)
这会产生正确的回报 -
length(pt)
1
1
1
1
1
1
1
1
2
2
3
等等。
为什么需要这样做?我没有在我的RETURN 子句中的任何地方使用变量p 或m。
我在shortestPath() 文档中找不到解释。
【问题讨论】:
标签: neo4j cypher graph-databases shortest-path