0

I want to use the id of a vertex that has prop_a=x to find other vertices which have this value in some other property.
Something like:

g.V().sideEffect(has('prop_a','x').id().as('val')).has('prop_b',__.select('val')).count()

But the above doesn't return the right result.
In addition, I need it to run efficiently on AWS Neptun.

Avner Levy
  • 6,601
  • 9
  • 53
  • 92

1 Answers1

2

Queries to create the data:

gremlin> g.addV().property(id,1).property('prop_a','x')
==>v[1]
gremlin> g.addV().property(id,2).property('prop_b',1)
==>v[2]

Query to get the desired data:

gremlin> g.V().
......1>   has('prop_a', 'x').
......2>   id().as('val').
......3>   V().as('b').
......4>   values('prop_b').
......5>   where(eq('val')).
......6>   select('b')
==>v[2]
  • This solution works but provides terrible performance in AWS Neptune. From the profile output: + not converted into Neptune steps: WherePredicateStep(eq(vid)),SelectOneStep(last,del),CountGlobalStep, WARNING: >> [WherePredicateStep(eq(vid))] << (or one of the children for each step) is not supported natively yet – Avner Levy Dec 22 '21 at 09:11
  • Just to ask whether they eventually "implemented" it - almost a year latter :-) The reason I ask is that it can be that it's impossible. That the particular crawling tactics is hitting the engine exactly where it's broken in principle. If 'id' is 'special/structural' for the engine => you can go to future id from a property but not to future property from past id - I mean you can but then you are "free crawling" i.e. without support of the structural index. – ZXX Nov 07 '22 at 13:34
  • I've tested this solution a few days ago with a more recent engine version and this solution works great while translated fully to Neptune native steps. – Avner Levy Dec 21 '22 at 17:35