4

It might be easy, but I am really struggling with this problem. I use gremlin python lib and aws neptune db. I know the vertex id, I just want to get the value(String type in python) of one of the properties of the vertex, and update it.

I have tried to do like this:

print(g.V(event['securityEventManagerId']).values('sourceData'))
print(g.V(event['securityEventManagerId']).property('sourceData'))
print(g.V(event['securityEventManagerId']).property('sourceData').valueMap())
.....

But I just print some python gremlin object like GraphTraversal, cannot retrieve the value as a string

Can anyone help me out?

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
Hongli Bu
  • 461
  • 12
  • 37

2 Answers2

5

You must use a terminal step, without them your query will not execute.

From tinkerpop documentation:

Typically, when a step is concatenated to a traversal a traversal is returned. In this way, a traversal is built up in a fluent, monadic fashion. However, some steps do not return a traversal, but instead, execute the traversal and return a result. These steps are known as terminal steps (terminal) and they are explained via the examples below.

In your case, you should do:

g.V(event['securityEventManagerId']).values('sourceData').next()
noam621
  • 2,766
  • 1
  • 16
  • 26
  • 3
    Also helpful in understanding this concept: http://tinkerpop.apache.org/docs/current/tutorials/the-gremlin-console/#result-iteration – stephen mallette Oct 07 '19 at 11:39
3

Here's a snippet:

for p in g.V(v).properties():
   print("key:",p.label, "| value: " ,p.value)

where v is the vertex you want to inspect.

Eddy Wong
  • 221
  • 3
  • 3