I'm trying create a property of vertice with static and dynamic value using selected properties. Here the code:
g.V('%s').as('source')
.until(or(hasLabel('target').has('v', '1'),loops().is(10)))
.repeat(__.in())
.outE('e').as('edge')
.inV().as('u')
.select('source')
.property(single, 'v', '1')
.property(single, union(constant('p_'),select('u').id()), select('e').properties('r').value())
This query is to copy property of edges as value and id of vertice as name of property with prefix 'p_'. The copy works, but the property name does not works, it's saving just prefix 'p_'.
Any ideas about this behaviour? I'm using tinkerpop 3.4.3, same the Neptune version.
Thanks!
The union() step in this traversal will not return a concatenation of the prefix and the property as you are hoping. Instead, it will return a single traverser for each item in the union(). In this case one containing "p_", one containing the id(), and one containing the "r" property.
Unfortunately, Gremlin does not have a string concatenation function that will accomplish this for you. See this below:
Concatenate Gremlin GraphTraversal result with string
As you are using Neptune the proposed solution in that answer will not work either as Neptune does not support lambdas in a traversal. Unfortunately, in this scenario the best way to accomplish this is likely to return the data to your application, concatenate the strings, and then update the property.