Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gremlin - Use custom String/UUID as Vertex ID

I'm trying to add a vertex with a custom ID, and while I've browsed many threads on this (e.g. here), I still can't get it to work for strings/UUIDs, only integer IDs. In fact, it appears only to accept numbers, but I'm not sure why.

gremlin> g.addV().property(T.id, 823749832)
==>v[823749832]

gremlin> g.addV().property(T.id, UUID.randomUUID())
Cannot cast java.util.UUID to java.lang.Number
Type ':help' or ':h' for help.
Display stack trace? [yN]

gremlin> g.addV().property(T.id, '823749832')
Cannot cast java.lang.String to java.lang.Number
Type ':help' or ':h' for help.
Display stack trace? [yN]

Any ideas?

like image 762
Ian Avatar asked Oct 21 '25 04:10

Ian


1 Answers

Unless something has changed recently JanusGraph used to only support Long values for custom (user provided) IDs. Different Graph engines allow differing amounts of flexibility in terms of what can be an ID.

See also...

https://github.com/JanusGraph/janusgraph/issues/45

like image 85
Kelvin Lawrence Avatar answered Oct 23 '25 22:10

Kelvin Lawrence



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!