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

我正在尝试关注文档
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索引查询结果以返回类似第二行的节点?

解决方法:

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

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

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

上一篇:Neo4j和Elasticsearch


下一篇:Neo4j - CQL