0

testing data:

vertex A has property 'a' value '1'
vertex B has outEdge  'e' to A
vertex B had property 'b' value '2'

how do I update 'a' to be value from 'b' in this case '2'?

I have tried this but not working

g.V().hasLabel('A').property('a', inE('e').outV().project('b').by('b').unfold())
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
Zhongmin
  • 1,684
  • 1
  • 16
  • 33

1 Answers1

0

Building the graph using...

gremlin> g.addV('A').property('a','1').as('a').
   ......1>   addV('B').property('b','2').as('b').
   ......2>   addE('e').from('b').to('a')

gremlin> g.V().valueMap()
==>[a:[1]]
==>[b:[2]]

You can use values from A to update B as follows (this is one way to write the query, there are alternative ways)

gremlin> g.V().hasLabel('B').as('b').V().hasLabel('A').property('a',select('b').values('b'))
==>v[42790]

gremlin> g.V().valueMap()
==>[a:[2]]
==>[b:[2]]              
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38