gremlin-python: what is a valid vertex custom id?

Viewed 1024

I want to add a vertex to JanusGraph by GremlinPython, and I already set graph.set-vertex-id=true in config, but I always get error:GremlinServerError: 500: Not a valid vertex id: 5678

I want to set a custom id to vertex, I only know the id should be a long type, some id set success, like:2048, 123456...; But more id set failed, it raise a error: GremlinServerError: 500: Not a valid vertex id: 5678.

My add vertex code is: vip = g.addV().property(T.id, 5678).property("name", "domain").property("value", "www.google.com").next()

Please tell me what is a valid id?

2 Answers

You can use a UUID with T.id ...

>>> from uuid import UUID
>>> vip = g.addV().property(T.id, UUID(int=5678)).property("name", "domain").property("value", "www.google.com").next()
>>> vip
v[00000000-0000-0000-0000-00000000162e]
>>> 0x162e
5678

The type is Long, but you need to send it in a string.

vip = g.addV().property(T.id, '5678').property("name", "domain").....

Related