Titan DB如何定义属性

时间:2015-04-27 10:52:07

标签: indexing titan

我是泰坦DB的新手,我想创建自己的数据库。

我想制作两种类型的顶点:用户和功能。两个顶点都将具有索引属性creation_date

更好的方法是只使用索引或两个z_creation_datef_creation_date创建一个属性类型creation_date吗?

1 个答案:

答案 0 :(得分:0)

您可以对两种顶点类型使用相同的属性,这就是.indexOnly()的用途。

mgmt = graph.getManagementSystem()
user = mgmt.makeVertexLabel("user").make()
feature = mgmt.makeVertexLabel("feature").make()
creation_date = mgmt.makePropertyKey("creation_date").dataType(Long.class).make()
mgmt.buildIndex("user_creation_date", Vertex.class).addKey(creation_date).indexOnly(user).buildCompositeIndex()
mgmt.buildIndex("feature_creation_date", Vertex.class).addKey(creation_date).indexOnly(feature).buildCompositeIndex()

另见:Label Constraints

相关问题