ABS
ABS

Reputation: 122

Gremlin Python - How to get ID from valueMap

I am fetching all the values from my graph into a list called nodes:

nodes = g.V().valueMap(True).toList()

For each node, I would like to get the id but I don't know how. E.g. I have a field called 'name'. To get name of the first vertex I would do something like this:

nodes[0][‘name’]

But I can't get the id of the first node using the same way. I don't know why. Maybe since it is automatically assigned and not a user created field, there is a different way of fetching it?

Upvotes: 2

Views: 1426

Answers (1)

noam621
noam621

Reputation: 2856

You need to import id enum.

from gremlin_python.process.traversal import T

nodes = g.V().valueMap(True).toList()

nodes[0][T.id]

Upvotes: 6

Related Questions