Search code examples
pythongremlintinkerpoptinkerpop3gremlin-server

How to get the latest property of vertex from apache gremlin?


How to get the latest property of vertex from apache gremlin?

With the same key, We can add multiple properties.

vp[status->new]
vp[pre_signed_url->https://e-voting.s3.]
vp[pre_signed_url->https://e-voting.s3.]
vp[pre_signed_url->https://e-voting.s3.]
vp[round_number->2]

In the above example, pre_signed_url has 3 different values.

How to get the latest/recently added property?


Solution

  • TinkerPop does not guarantee that sets and lists are retrieved in any specific order. It’s possible with some implementations that the tail is the latest but you should not rely on that. Each property in a set or list will have an ID. In some cases you can use that but again that’s not universally reliable.

    Therefore, if the database you are using supports meta properties you could give each set member a date or time stamp. However, I think the simplest solution is just to maintain a latest URL properly on each vertex.