0

I'd like to get a list of edge properties in the form of

[ {'src': nodeid, 'dst': nodeid, 'item': itemid},
  {'src': nodeid, 'dst': nodeid, 'item': itemid},
  ...
]

Refer to this question, I formulate the query as the following in 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()

However, I got the following error

TypeError: 'Column' object is not callable

I am able to get a list of 'src' and 'dst' with

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

Did i miss out any python keyword? Or may I know what's the limitation lies in gremlin python?


Updates:

In my case, I do have a workaround for this. Only edges contain (src, dst, item) will be extracted however.

g.V(user_list).bothE().hasLabel('share_item').dedup(). \
                has('item'). \
                project('src','dst'). \
                    by(outV().id()). \
                    by(inV().id()) \
                    by('item'). \
                toList()
twfx
  • 1,664
  • 9
  • 29
  • 56

1 Answers1

0

My guess is that values('item_id') is somehow being confused with the Column.values enum. What you want there is the traversal step values() which is exposed from the __ class. Having imported the __ class, please try changing your code to:

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()
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • I got "TypeError: values() takes no arguments (1 given)" with this. BTW, I did import "from gremlin_python.process.graph_traversal import __" and "statics.load_statics(globals())" – twfx Dec 06 '18 at 03:02