If there are no edges, then this isn't a terribly "graphy" query so this might look a little clumsy. I think you would have to use some form of mid-traversal V()
. I demonstrated here with a little data:
gremlin> g.addV('a').property('x1',1).property('x2',2).
......1> addV('b').property('y1',1).property('y2',2).
......2> addV('b').property('y1',2).property('y2',3).iterate()
gremlin> g.V().hasLabel('a').as('a').
......1> V().hasLabel('b').as('b').
......2> where('a', eq('b')).
......3> by('x1').
......4> by('y1').
......5> where('a', eq('b')).
......6> by('x2').
......7> by('y2').
......8> select('a','b').
......9> by(valueMap(true))
==>[a:[label:a,id:0,x1:[1],x2:[2]],b:[label:b,id:3,y1:[1],y2:[2]]]
I'm not sure if there isn't a nicer way to do this. Depending on how large your dataset is, this could be a tremendously expensive traversal and would probably be a better candidate for a form of OLAP traversal using Gremlin Spark.