vertexLabel

Synopsis

schema.vertexLabel('vertexLabel').[ partitionKey(propertyKey, [ partitionKey(propertyKey) ] ].[ clusteringKey(propertyKey) ].[ ttl ].[ properties(property, property) ].[ index ].[ partition() ].[ cache() ].[ ifNotExists() ].[ create() | add() | 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 lifecycle 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()

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 are 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()

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com