I am having an edge(say edge) between two vertices(say v1 and v2). And edge direction is from v1 to v2. In my current situation, I have to count the no. of edges are incoming to v2 based on some condition. Now I am able to count the number of edges, but I am not able to retrieve the data of v2.
g.V().hasLabel('V2').has('type','c').as('p').project('v2Data').by(select('p').inE('edge').count().is(gt(5)).valueMap(true))
By the above approch, I have got an error
java.lang.Long cannot be cast to org.apache.tinkerpop.gremlin.structure.Element
The other approach I tried is,
g.V().hasLabel('v2').has('type','c').as('p').project('v2Data').by(select('p').inE('edge').count().is(gt(5)).select('p').valueMap(true))
The provided traverser does not map to a value: v[286724240]->[SelectOneStep(last,p), NoOpBarrierStep(2500), JanusGraphVertexStep(IN,[willingToPlayAt],edge), RangeGlobalStep(0,6), CountGlobalStep, IsStep(gt(5)), SelectOneStep(last,p), NoOpBarrierStep(2500), PropertyMapStep(value)]
I have tried this stack overflow answer fold() approach
I want my output as v2data = [{},{}]
reference:
g.addV('game').property('id',1).as('1').
addV('game').property('id',2).as('2').
addV('game').property('id',3).as('3').
addV('game').property('id',4).as('4').
addV('game').property('id',5).as('5').
addV('game').property('id',6).as('6').
addV('loc').property('id',p1).as('p1').
addV('loc').property('id',p2).as('p2').
addE('edge').from('1').to('p1').
addE('edge').from('2').to('p1').
addE('edge').from('3').to('p1').
addE('edge').from('4').to('p1').
addE('edge').from('5').to('p1').
addE('edge').from('6').to('p1').
addE('edge').from('1').to('p2').
addE('edge').from('2').to('p2');
query:
g.V().hasLabel('loc').has('type','c').
project('locData').
by(where(inE('edge').count().is(gt(5))).valueMap(true).fold())
Expected output:
{locData=[{id=[p1],....}]}
because gt(5) is satisfied only for loc with id=p1.
But I am getting my result as
{locData=[{id=[p1],....}]}
{locData=[]}(p2 is not satisfied with my condition.)