vertexLabel

How to create a vertex label.

Synopsis

schema.vertexLabel('vertexLabel').
  [ partitionKey(propertyKey, [ partitionKey(propertyKey) ] ].
  [ clusteringKey(propertyKey) ].
  [ ttl ].
  [ ifNotExists() ].
  [ index ].
  [ properties(property, property).[ add() | drop() ]].
  [ partition() ].
  [ cache() ].
  [create() | drop() | describe() | exists() ]

Description

A vertex label specifies a type of vertex that can be stored in DSE Graph. A vertex label can have properties defined, a partition key, clustering key, indexes, cache, and a time-to-live (TTL) to determine the life cycle of an vertex.

DSE Graph limits the number of vertex labels to 200 per graph.

Examples

Create a vertexLabel author:
schema.vertexLabel('author').create()
Create a vertexLabel ingredient if the vertex label doesn't already exist:
schema.vertexLabel('ingredient').ifNotExists().create()

For partition and clustering keys, see partitionKey-clusteringKey.

Add properties to a vertexLabel:
schema.vertexLabel('author').properties('location','restaurant').add()

For indexes, see each index entry (edge index, property index, vertex index) in the Schema API.

Cache all properties for author vertices up to an hour (3600 seconds):
schema.vertexLabel('author').cache().properties().ttl(3600).add()
Enabling property cache causes index queries to use IndexCache for the specified vertex label.
Cache both incoming and outgoing created edges for author vertices up to a minute (60 seconds):
schema.vertexLabel('author').cache().bothE('created').ttl(60).add()
Partition a vertexLabel based on a particular edgeLabel:
schema.vertexLabel('author').partition().inE('created').add()
Create a time-to-live (TTL) for an vertexLabel of 60 seconds. Setting a TTL will expire all vertices inserted with the vertexLabel at the set TTL value:
schema.vertexLabel('author').ttl(60).create()
Note: DSE Graph sets TTL differently from the DSE database. The DSE database sets TTL per mutation (insertion or update) or can inherit a default value from the table schema. DSE Graph sets TTL per vertex label or edge label, and all vertices or edges will be affected by the TTL setting. DSE Graph cannot set TTL for an individual vertex or edge.
Check if a vertexLabel exists:
schema.vertexLabel('author').exists()
Get the schema creation command for a vertexLabel using the describe() command:
schema.vertexLabel('author').describe()
Remove a vertex label with the drop() command:
schema.vertexLabel('author').drop()
Remove a property gender from a vertex label:
schema.vertexLabel('author').properties('gender').drop()