Question

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

Était-ce utile?

La solution

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top