我正在嘗試使用 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 關注
- 186 瀏覽
添加回答
舉報
0/150
提交
取消