Re: How can i keep the vertex which i want to add is unique?

Jason Plurad <plu...@...>

Check out the documentation for creating a unique composite index.

Here's an example Gremlin Console session which creates a unique composite index on name. When you attempt to set a non-unique name, it will throw a SchemaViolationException.

gremlin> graph ='inmemory')
> mgmt = graph.openManagement()
> name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(Cardinality.SINGLE).make()
> nameIndex = mgmt.buildIndex('nameIndex', Vertex.class).addKey(name).unique().buildCompositeIndex()
> mgmt.commit()
> graph.addVertex('name', 'huupon')
> graph.addVertex('name', 'huupon')
Adding this property for key [name] and value [huupon] violates a uniqueness constraint [nameIndex]

-- Jason

On Wednesday, June 21, 2017 at 4:34:22 AM UTC-4, huupon wrote:
Hi, all:

       How can i keep the vertex which i want to add is unique?  get and add?  whether have any other methods to add unique vertex ?

Join { to automatically receive all group messages.