Gremlin-Server 添加具有多个属性的顶点 (Titan 1.0.0)

Gremlin-Server Add Vertex with Multiple Properties (Titan 1.0.0)

我正在创建一个 Titan 图(由 Dynamodb 支持);我正在使用 Titan 1.0.0 和 运行 Gremlin-Server 3(在 TinkerPop3 上)。

我正在尝试将一个顶点添加到我的图形中,并在一行中添加一个标签和多个属性。我可以添加带有标签和单个 属性 的顶点,并且可以在顶点创建后向其添加多个属性,但似乎我无法一次完成所有操作。

为了测试,我在 gremlin shell 中使用了 运行 命令,但最终用例是通过 REST api 与它交互(这已经可以正常工作了)。

请注意,我会在每笔交易后回滚,这样我就有了一个干净的状态。

这是我开始会话的方式:

gremlin> graph = TitanFactory.open('conf/gremlin-server/dynamodb.properties')
==>standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]]
gremlin> g = graph.traversal()
==>graphtraversalsource[standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]], standard]

我可以创建一个带有标签和单个 属性 的顶点,如下所示:

gremlin> graph.addVertex('date_of_birth').property('date_of_birth','1949-01-01')
==>vp[date_of_birth->1949-01-01]
gremlin> g.V().hasLabel('date_of_birth').has('date_of_birth','1949-01-01').valueMap()
==>[date_of_birth:[1949-01-01]]

我还可以创建一个顶点,然后通过从我刚创建的顶点开始的遍历附加许多属性:

gremlin> v1 = graph.addVertex('date_of_birth')
==>v[409608296]
gremlin> g.V(v1).property('date_of_birth','1949-01-01').property('year_of_birth',1949).property('date_of_birth','1949-01-01').property('day_of_birth',1).property('age',67).property('month_of_birth',1)
==>v[409608296]
gremlin> g.V(v1).valueMap()
==>[day_of_birth:[1], date_of_birth:[1949-01-01], month_of_birth:[1], age:[67], year_of_birth:[1949]]

一切都很好,但我试图避免进行 2 次调用来实现这个结果,所以 我想一次创建具有所有这些属性的顶点。本质上,我希望能够执行如下操作,但它失败了超过 1 .property():

gremlin> graph.addVertex('date_of_birth').property('date_of_birth','1949-01-01').property('year_of_birth',1949).property('date_of_birth','1949-01-01').property('day_of_birth',1).property('age',67).property('month_of_birth',1)
No signature of method: com.thinkaurelius.titan.graphdb.relations.SimpleTitanProperty.property() is applicable for argument types: (java.lang.String, java.lang.String) values: [date_of_birth, 1949-01-01]

我也尝试过将 1 .property() 与多个属性一起使用(以及我能想到的所有其他语法变体),但它似乎只捕捉到第一个:

gremlin> graph.addVertex('date_of_birth').property('date_of_birth','1949-01-01','year_of_birth',1949,'date_of_birth','1949-01-01','day_of_birth',1,'age',67,'month_of_birth',1)
gremlin> g.V().hasLabel('date_of_birth').has('date_of_birth','1949-01-01').valueMap()
==>[date_of_birth:[1949-01-01]]

我已经查看了所有我能找到的所有来源的文档,但我找不到关于此 "all at once" 方法的任何内容。有没有人以前做过这个或知道如何做?

提前致谢!

Chapter 3 Getting Started of the Titan docs, the GraphOfTheGodsFactory.java 中所述,源代码显示了如何添加带有标签和多个属性的顶点。

saturn = graph.addVertex(T.label, "titan", "name", "saturn", "age", 10000);

TinkerPop 文档中 addVertex 步骤(以及许多其他步骤)中的方法 addVertex(Object... keyValues) ultimately comes from Graph interface defined by Apache TinkerPop. Titan 1.0.0 uses TinkerPop 3.0.1, and you can find more documentation