使用Python REST客户端查询neo4j节点
我在索引中有一些节点,具有以下属性:
{'user_id': u'00050714572570434939', 'hosts': [u'http://shyjive.blogspot.com/'], 'follows': ['null']}
现在我有了索引,我正在尝试一个简单的查询来获取这些节点,如下所示:
index = gdb.nodes.indexes.create('blogger2')
uid = gdb.nodes.create()
uid["hosts"] = ['http://shyjive.blogspot.com/']
uid["user_id"] = "00050714572570434939"
uid["follows"] = ['null']
print index["user_id"]["00050714572570434939"][:]
但是这个返回的是 [],这到底是怎么回事呢!!
我之所以在 Python 中使用列表,是因为在 neo4j 的开发者群组里有人建议这样做,我想把多个属性值存储到节点中,所以我在这里用列表而不是数组。
1 个回答
1
首先,你需要给这个节点建立索引。如果你没有使用自动索引,那么使用neo4j-rest-client的代码如下:
index["user_id"]["00050714572570434939"] = uid
现在你已经有了:
>>> index["user_id"]["00050714572570434939"][:]
[<Neo4j Node: http://localhost:7474/db/data/node/38>]