[英]Gremlin - how to assign a list of values to a new property, for multiple vertices
說我有三個頂點與ID的列表123
, 456
和789
。
g.V([123,456, 789])
我如何添加一個新的屬性,比如說testproperty
,我有一個要同時添加的值列表['a', 'b', 'c']
?
偽gremlin代碼(用於說明) 是無效的:
g.V([123,456, 789]).property('testproperty', ['a', 'b', 'c'])
明確地說,我想要兩個列表之間的映射,因此gV(123).property('testproperty', 'a')
, gV(123).property('testproperty', 'b')
等。
因此, gV([123,456,789]).valueMap()
應該返回:
==>{testproperty=[a]}
==>{testproperty=[b]}
==>{testproperty=[c]}
這是一種實現方法:
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]]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.