0

I want to get all v's s.t v.id == v.prop1 for some property named prop1 (which has a string value).

I'm able to compare 2 props of the same vertex thanks to this answer using:

g.V().as('v').where(eq('v')).by('prop1').by('prop2')

but using:

g.V().as('v').where(eq('v')).by(id()).by('prop1')

Doesn't work and returns an empty response.

After a quick investigation I realized that the equality check fails due to UUID not being the same type as string. I also saw one approach to change the configuration on how gremlin calculates equality.

Is there any way to do that without changing the configuration of my graph? Thanks.

Danya
  • 21
  • 2

1 Answers1

0

In the example below we find V(3) and then look for a vertex with an id property, that matches the ID for V(3)

// Create a test vertex
g.addV('test').property('id','3')

v[8ebf4e34-073f-10b6-c6c9-f553b3a81e6c]

// Find any matches
g.V('3').as('a').V().has('id').where(eq('a')).by('id').by(id())

v[8ebf4e34-073f-10b6-c6c9-f553b3a81e6c]

You can re-arrange the query any way you like, but the key is that there has to be something to compare to. Otherwise you are looking for any vertex that has an id and "id" property that are the same - probably not what you are looking for.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38