Titan根据属性键创建唯一的顶点

时间:2013-09-16 05:59:45

标签: unique vertex gremlin titan

我想创建一个没有重复属性的顶点,例如name

我关注了https://github.com/thinkaurelius/titan/wiki/Vertex-Centric-Indices

页面

然而,它对我不起作用

gremlin>g.makeType().name('dom').unique(OUT).dataType(String.class).indexed(Vertex.class).makePropertyKey()
==>v[36028797018965714]
gremlin> u2 = g.addVertex([dom:'def.com'])
==>v[480020]
gremlin> u2 = g.addVertex([dom:'def.com'])
==>v[480024]

我可以为同一个dom属性创建一个vertext吗?

提前致谢

1 个答案:

答案 0 :(得分:3)

您需要将类型定义为unique(BOTH)。您可以阅读有关类型here的更多信息。

gremlin> g = TitanFactory.open('/tmp/titan')
==>titangraph[local:/tmp/titan]
gremlin> g.makeType().name('dom').unique(BOTH).dataType(String.class).indexed(Vertex.class).makePropertyKey()
==>v[36028797018963978]
gremlin> g.commit()
==>null
gremlin> u2 = g.addVertex([dom:'def.com'])
==>v[4]
gremlin> u2 = g.addVertex([dom:'def.com'])
The given value is already used as a property and the property key is defined as in-unique
Display stack trace? [yN] n
gremlin>
相关问题