cassandradatastax-enterprisedatastax-java-driverdatastax-enterprise-graph

Why does inserting a vertex with the same property not throw an error in DSE Graph?


I am using Dse graph version 5.x.

I have created a schema using Dse studio which uses gremlin query.

What I am trying to do is:

I want to index my graph based on vertex property called 'name'

Here is what I get when I do schema.describe() Schema Image

Here is what I get when I do g.V() graph table

As you can clearly see, I have index my vertex label type with property name.

But when I insert multiple vertex (of label type) with same name it accept it without error.

Ideally because of indexing it should show error on inserting vertex with same property `name'.


Solution

  • indexing in DSE Graph is a performance optimization operation not a Referential Integrity operation. Currently there is no mechanism that will "reject" creating a new index if one exists with the same property. We have this feature request on our roadmap. In the interim, it is possible to achieve "upsert" style semantics with DSE Graph by leveraging Custom IDs as described here - http://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/using/createCustVertexId.html?hl=custom%2Cid