3

プロパティを頂点プロパティに追加したい。グレムリンでは、値が「place1」である頂点プロパティ「places」にプロパティ「phone」を追加します

g.V(v).properties('places').hasValue('place1').property('phone',"123456789")

トランザクションコミットを使用しなくても問題なく動作しました。しかし、Javaコードでこの方法を使用すると、うまくいきませんでした。では、Javaコードでは、プロパティを頂点プロパティに追加する方法は? お手伝いありがとうございます。

4

1 に答える 1

5

iterate()横断する必要があります。

g.V(v).properties('places').hasValue('place1').property('phone',"123456789").iterate()

1 つの考え方: 元のコード スニペットはクエリですが、それでも実行する必要があります。

違いを示す完全な Gremlin コンソールの例を次に示します。

gremlin> graph = TitanFactory.open('inmemory'); g = graph.traversal()
==>graphtraversalsource[standardtitangraph[inmemory:[127.0.0.1]], standard]
gremlin> v = graph.addVertex('name','jenny','places','home')
==>v[4264]
gremlin> g.V(v).properties('places').hasValue('home')
==>vp[places->home]
gremlin> g.V(v).properties('places').hasValue('home').property('phone','867-5309'); 'traversal was not iterated'
==>traversal was not iterated
gremlin> g.V(v).properties('places').hasValue('home').properties()
gremlin> g.V(v).properties('places').hasValue('home').property('phone','867-5309').iterate(); 'iterated!'
==>iterated!
gremlin> g.V(v).properties('places').hasValue('home').properties()
==>p[phone->867-5309]
gremlin> graph.tx().commit()
==>null

データを永続化する場合は、トランザクションをコミットする必要があります。

于 2016-01-07T16:01:27.177 に答える