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>