Search code examples
c#azureazure-cosmosdbgremlinazure-cosmosdb-gremlinapi

Gremlin cosmos: How to copy a property value of edge as vertex property inside a repeat command


g.V().has(id,'xxx').repeat(outE('x').
has('b',gte(1588919200)).has('b',lte(1589128800)).inV())
.times(2).emit().property('a',b)

Edge has a property 'b' and vertex has a property 'a'.

For vertices satisfying certain conditions i want to copy edge's 'b' property value as vertex's 'a' property value.

And this has to be done for all vertices connected by 'x' edge upto 2 levels.


Solution

  • Not sure if you want value 'b' from the first edge for everyone or each one gets is own edge value.

    for first edge value for all:

    g.V('xxx').as('v').
      outE('child').has('b', gte(1)).
      has('b', lte(10)).as('e').select('v').
      repeat(out('child')).emit().times(2).
      property(single, 'a', select('e').
        values('b'))
    

    each vertex gets the connected edge value:

    g.V().has('root').repeat(outE('child').
    has('b',gte(1)).has('b',lte(10)).as('e').inV())
    .times(2).emit().property(single, 'a', select('e').
        values('b'))
    

    example: https://gremlify.com/av