【问题标题】:neo4j query for a node using python rest clientneo4j 使用 python rest 客户端查询节点
【发布时间】:2013-03-22 07:44:03
【问题描述】:

我在索引中有具有以下属性的节点:

{'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"][:]

这个返回[],这里有什么问题!!

为什么我在 neo4j 组的开发人员建议的那样在 python 中使用列表的原因是我想将多个属性值存储到节点,所以我在这里使用列表而不是数组

【问题讨论】:

    标签: python nosql neo4j


    【解决方案1】:

    您首先需要索引节点。如果您没有使用automatic indexingneo4j-rest-client 的代码将是:

    index["user_id"]["00050714572570434939"] = uid
    

    现在你有:

    >>> index["user_id"]["00050714572570434939"][:]
    [<Neo4j Node: http://localhost:7474/db/data/node/38>]
    

    【讨论】:

    • 感谢您的时间,但是当我尝试索引列表时,因为我想为节点的属性添加多个值,例如:uid = gdb.nodes.create() index["user_id"][ x] = uid index["hosts"][source] = uid index["follows"][dest] = uid 以上 source 和 dest 是列表,所以它给我错误:tx = tx or value[1] IndexError: list index超出范围
    • 不幸的是,尚不支持将列表作为索引键。但它来了!
    猜你喜欢
    • 2015-11-01
    • 2018-04-27
    • 1970-01-01
    • 1970-01-01
    • 2021-03-02
    • 2020-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多