Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python neo4jrestclient索引结果返回Iterable而不是node/url?_Python_Indexing_Neo4j_Neo4j.py - Fatal编程技术网

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

Python neo4jrestclient索引结果返回Iterable而不是node/url?,python,indexing,neo4j,neo4j.py,Python,Indexing,Neo4j,Neo4j.py,我正试着跟着医生走 我希望索引查询返回一个节点,但它会返回一个“Iterable:node”: 印刷品: <Neo4j Iterable: Node> <Neo4j Node: http://localhost:7474/db/data/node/157> 如何获取neo4jrestclient索引查询结果以返回第二行这样的节点?索引查找可以返回多个节点,因此在本例中,它返回一个迭代器。要获取迭代器中的下一项,请执行.next(): 请参阅:正如@espeed所指

我正试着跟着医生走

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

印刷品:

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


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

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


请参阅:

正如@espeed所指出的,调用
。next()
将为您提供索引中的下一个节点。 您还可以在迭代器上进行迭代:

for node in playerIndex["player_id"]["Homer"]:
    print node, "\n", playerNode
或者只需使用切片
[:]
在迭代器中获取所有结果:

print playerIndex["player_id"]["Homer"][:], "\n", playerNode
客户机以这种方式运行,因为任何索引查询总是返回元素列表,即使只有一个元素。因此,处理这个问题的最佳方法是使用具有延迟加载的迭代器

for node in playerIndex["player_id"]["Homer"]:
    print node, "\n", playerNode
print playerIndex["player_id"]["Homer"][:], "\n", playerNode