【问题标题】:Query Edge Nodes & Edge Properties查询边缘节点和边缘属性
【发布时间】:2018-12-05 04:20:12
【问题描述】:

我想以

的形式获取边缘属性列表
[ {'src': nodeid, 'dst': nodeid, 'item': itemid},
  {'src': nodeid, 'dst': nodeid, 'item': itemid},
  ...
]

参考this question,我在gremlin_python中将查询表述如下:

g.V(user_list).bothE().hasLabel('share_item').dedup(). \
                project('src','dst','item'). \
                    by(outV().id()). \
                    by(inV().id()) \
                    by(coalesce(values('item_id'),constant(''))). \
                .toList()

但是,我得到了以下错误

TypeError: 'Column' object is not callable

我可以使用 'src' 和 'dst' 的列表

g.V(user_list).bothE().hasLabel('share_item').dedup(). \
                project('src','dst'). \
                    by(outV().id()). \
                    by(inV().id()) \
                .toList()

我错过了任何 python 关键字吗?或者我可以知道gremlin python的限制是什么?


更新:

就我而言,我确实有一个解决方法。但是,只会提取包含 (src, dst, item) 的边。

g.V(user_list).bothE().hasLabel('share_item').dedup(). \
                has('item'). \
                project('src','dst'). \
                    by(outV().id()). \
                    by(inV().id()) \
                    by('item'). \
                toList()

【问题讨论】:

    标签: python python-2.7 gremlin tinkerpop tinkerpop3


    【解决方案1】:

    我的猜测是 values('item_id') 在某种程度上与 Column.values 枚举混淆了。您想要的是从 __ 类公开的遍历步骤 values()。导入 __ 类后,请尝试将代码更改为:

    g.V(user_list).bothE().hasLabel('share_item').dedup(). \
                project('src','dst','item'). \
                    by(outV().id()). \
                    by(inV().id()) \
                    by(coalesce(__.values('item_id'),constant(''))). \
                .toList()
    

    【讨论】:

    • 我得到了“TypeError:values() 没有参数(1 个给定)”。顺便说一句,我确实导入了“from gremlin_python.process.graph_traversal import __”和“statics.load_statics(globals())”
    猜你喜欢
    • 2015-05-23
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多