I have a vertex that has a 'title' property. I have other vertices that have outgoing edges that have multiple properties. I'm trying to find vertices that have outgoing edges where the 'title' property value is a property key on the edge.
For example Vertex A has property {'title': ['lebron']} and Edge B has property {'lebron': 'basketball'}.
This is the example graph I have:
g.addV('person').property(id, 'bob')
g.addV('person').property(id, 'alice').addE().to(__.V('bob')).property('lebron', 'basketball')
g.addV('player').property('title', 'lebron').addE().from(__.V('bob'))
This is the query I currently came up with that isn't working:
g
.V('alice')
.outE()
.as('b')
.otherV()
.hasId('bob')
.as('c')
.select('b')
.properties()
.key()
.fold()
.as('k')
.select('c')
.outE()
.otherV()
.has('title', within('k')))
.valueMap('title')
.toList();
Try this:
g
.V('alice')
.outE()
.as('b')
.otherV()
.hasId('bob')
.as('c')
.select('b')
.aggregate('keys').by(properties().key())
.select('c')
.out()
.where(values().where(within('keys')))
.valueMap('title')
.toList()