I want to query in Amazon Neptune graph db two values belonging to same type of vertex. How can I achieve this in Gremlin ?
e.g.
If we write a query in sql it would look like this -
select * from table where id in ('ID1', 'Id2')
%%gremlin explain
g.V().has('Parts', '~id', 'ABCD')
.has('Parts', '~id', 'PQRS').values()
Based on the SQL example, the equivalent Gremlin would be:
g.V().has('Parts', '~id',within( 'ABCD','PQRS')).values()
However, if ~Id
is the actual vertex ID, then you can just do:
g.V().has('Parts', id, within( 'ABCD','PQRS')).values()
but given an ID is unique, you don't need to check the label if you know it should be of that type:
g.V().hasId('ABCD','PQRS').values()
or even just
g.V('ABCD','PQRS').values()