Translate the gremlin command to the corresponding gremlin-python statement

97 views
Skip to first unread message

Yingjie Li

unread,
Aug 31, 2020, 10:52:23 AM8/31/20
to Gremlin-users
Hello,

Can anyone help translate gremlin-command :g.V().as("a").out().as("b").select('a','b').by("id").groupCount().unfold().filter(select(values).is(gt(1))) 

to the corresponding gremlin-python statement ?

I tried with 

g.V().as_('a').out().as_('b').select('a','b').by('id').groupCount().unfold().filter(__.select(Column.values).is_(P.gt(1)))
and seems it is not recognized. 

Thank you,

Yingjie




Kelvin Lawrence

unread,
Aug 31, 2020, 2:25:29 PM8/31/20
to Gremlin-users
A couple of questions:

1. What error message are you seeing?
2. Is "id" meant to be a property or the actual vertex id (as in T.id)

Cheers
Kelvin

Yingjie Li

unread,
Sep 2, 2020, 5:54:46 AM9/2/20
to Gremlin-users
The "id" is a property. When I ran below (added .toList()  at the the end)
g.V().as_('a').out().as_('b').select('a','b').by('id').groupCount().unfold().filter(__.select(Column.values).is_(P.gt(1))).toList()
Got  error: TypeError: unhashable type: 'dict'

In gremlin, with g.V().as("a").out().as("b").select('a','b').by("id").groupCount().unfold().filter(select(values).is(gt(1))), the result is 

==>{a=A.sensor14, b=A.sensor51}=3

==>{a=A.sensor14, b=A.sensor50}=3

which is as expected. 

Seems I have to change the python code in the similar way as the last post in this link. Still trying to figure out the right syntax.

Yingjie

Stephen Mallette

unread,
Sep 8, 2020, 11:09:15 AM9/8/20
to gremli...@googlegroups.com
In 3.5.0 we will support dict as a key in python:


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/991c27aa-4cfc-42c6-b265-20781d13025en%40googlegroups.com.

Yingjie Li

unread,
Sep 10, 2020, 10:37:13 AM9/10/20
to Gremlin-users
Good to know. For now, I got the problem solved by following this link:
Reply all
Reply to author
Forward
0 new messages