0

Say I have a list of three vertices with IDs 123, 456, and 789.

g.V([123,456, 789])

How can I add a new property called say testproperty, for which I have a list of values, ['a', 'b', 'c'], which I want to add at the same time?

The pseudo gremlin code - for illustration - and which doesn't work is:

g.V([123,456, 789]).property('testproperty', ['a', 'b', 'c'])

To be clear, I want a mapping between the two lists, so g.V(123).property('testproperty', 'a'), g.V(123).property('testproperty', 'b') etc.

So, g.V([123,456,789]).valueMap() should return:

==>{testproperty=[a]}
==>{testproperty=[b]}
==>{testproperty=[c]}
Ian
  • 3,605
  • 4
  • 31
  • 66
  • that Gremlin looks right to me if you're trying to add "testproperty" with the specified value to each of those three vertices. can you elaborate on what doesn't work? – stephen mallette Jul 22 '19 at 18:23
  • Sure thing. It raises the Exception: `Property value [[a, b, c]] is of type class java.util.ArrayList is not supported` – Ian Jul 22 '19 at 18:37
  • Hi Stephen, I think I may have miscommunicated my end goal originally, and have made it more clear in an edit. – Ian Jul 22 '19 at 19:09

1 Answers1

1

Here's one way to do it:

gremlin> data = [1:'a',2:'b',3:'c']
==>1=a
==>2=b
==>3=c
gremlin> g.inject(data).as('d').
......1>   V(data.keySet()).as('v').
......2>   property('testproperty', select('d').select(select('v').by(T.id)))
==>v[1]
==>v[2]
==>v[3]
gremlin> g.V(data.keySet()).valueMap(true)
==>[id:1,label:person,testproperty:[a],name:[marko],age:[29]]
==>[id:2,label:person,testproperty:[b],name:[vadas],age:[27]]
==>[id:3,label:software,testproperty:[c],name:[lop],lang:[java]]
stephen mallette
  • 45,298
  • 5
  • 67
  • 135