Dse graph indexing on vertex label using Java

150 Views Asked by At

I am using Datastax Dse grap (5.x) java driver version 1.1.1 beta.

My use case is that I can not allow more than one vertex to have same vertex label.

For that I want to create index on vertex label.

I found this below code on Datastax official website schema.vertexLabel('recipe').index('byRecipe').secondary().by('name').add()

But, this datastax tutorial lacks two things

  • How to create index on vertex label
  • How to execute this using java

My question is how to index Dse graph on Vertex label using java?

2

There are 2 best solutions below

0
On

To implement this, you would execute the example as a graph statement. It is typically recommended to create your schema outside of your application, traversal code base.

0
On

If you are correct in stating that "you cannot allow more than one vertex to have the same vertex label", I think you need to reconsider your data model. A vertex label is intended to identify a group of vertices, with a vertex property distinguishing several vertices from one another.

If you created a vertex label "vtype" and a property "name" that identified each instance "vtype1, vtype2, etc.", then the index could be: schema.vertexLabel('vtype').index('byVType').secondary().by('name').add()