我正在尝试使用 Neo4j Go 驱动程序。我已经编写了这个代码片段来获取从节点 1 到节点 5 的路径,但是无法正确获取 api 中提到的结果。result, err = session.Run("match (n:Xyz{title:1}),(m:Xyz{title:5}),p=allShortestPaths((n)-[*]->(m)) return p",nil) if err != nil { return "",err } for result.Next() { keys := result.Record().Keys() fmt.Println(keys) values_NEO := result.Record().Values() nodes := values_NEO[0].Nodes() labels := nodes.Labels() fmt.Println(labels) }我收到以下错误:values_NEO[0].Nodes undefined (type interface {} is interface with no methods)我的图表是这样的:
1 回答

隔江千里
TA贡献1906条经验 获得超10个赞
result.Record().Values()
返回[]interface{}
。
所以 的 类型values_NEO[0]
是interface{}
,它没有一个名为 的方法Nodes()
。具有该方法的类型是Path
.
我对 neo4j 不熟悉,但如果您希望values_NEO[0]
使用 type Path
,则必须输入 assert,如下所示values_NEO[0].(neo4j.Path).Nodes()
:
- 1 回答
- 0 关注
- 160 浏览
添加回答
举报
0/150
提交
取消