문제

I want to create a vertexs that do not have duplicate property, e.g., name

I followed the page https://github.com/thinkaurelius/titan/wiki/Vertex-Centric-Indices

However, it does not work for me

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]

Can I just have one vertext created for the same dom property?

Thanks in advance

도움이 되었습니까?

해결책

You need to define your type as unique(BOTH). You can read more about types 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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top