【发布时间】:2014-03-26 14:27:33
【问题描述】:
我正在使用 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 都相当陌生,并且对索引没有非常复杂的理解,所以如果有一个答案可以帮助教育我和其他人,那就太好了,如果这代表一个错误,会也很高兴知道:)
谢谢!
【问题讨论】: