gpt4 book ai didi

python - neo4jrestclient 索引结果返回 Iterable 而不是 node/url?

转载 作者:太空宇宙 更新时间:2023-11-03 13:50:17 25 4
gpt4 key购买 nike

我正在尝试遵循文档 http://readthedocs.org/docs/neo4j-rest-client/en/latest/indices.html

我希望索引查询返回一个节点,但它返回的是“Iterable: Node”:

db = GraphDatabase("http://localhost:7474/db/data")
playerIndex = db.nodes.indexes.get("index1")
playerNode = db.nodes.create(player_id = "Homer")
playerIndex.add("player_id", "Homer", playerNode)
print playerIndex["player_id"]["Homer"], "\n", playerNode

打印:

<Neo4j Iterable: Node>
<Neo4j Node: http://localhost:7474/db/data/node/157>

如何获取 neo4jrestclient 索引查询结果以返回像第 2 行这样的节点?

最佳答案

索引查找可以返回多个节点,因此在这种情况下,它返回一个迭代器。要获取迭代器中的下一项,请执行 .next():

print playerIndex["player_id"]["Homer"].next(), "\n", playerNode

参见:https://github.com/versae/neo4j-rest-client/blob/master/neo4jrestclient/iterable.py

关于python - neo4jrestclient 索引结果返回 Iterable 而不是 node/url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10526593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com