我正在使用 py2neo 1.6.4 和 neo4j 2.0.1,并且在访问索引节点时发现了一些奇怪的地方。特别是,通过 index 访问的索引节点不会返回与通过 id 访问的节点相同的对象。
例如:
>>> graph_db.get_or_create_indexed_node('index','key',1)
Node('http://localhost:7474/db/data/node/1')
>>> graph_db.get_indexed_node('index','key',1)
Node('http://localhost:7474/db/data/node/1') #get works fine after create
>>> graph_db.get_indexed_node('index','key',1).exists
True #the node exists in the db
>>> graph_db.get_indexed_node('index','key',1)._id
1 #the id for the node
>>> graph_db.node(1)
Node('http://localhost:7474/db/node/ #note that this is different than the query on the index
>>> graph_db.node(1).exists
False #node does not exist in db when accessed by id
因此,通过 id 访问时返回的节点实际上并不存在于数据库中,即使返回的 id 正是分配给索引节点的那个。
我对 neo4j 和 py2neo 都相当陌生,并且对索引没有非常复杂的理解,所以如果有一个答案可以帮助教育我和其他人,那就太好了,如果这代表了一个很好的错误也知道:)
谢谢!