propertyKey

Synopsis

propertyKey('name').type().[ single() | multiple() ].[ ttl ].[ properties(metadata_property) ].[ ifNotExists() ].[ create() | add() | describe() | exists() ]

Description

Property keys are created for vertices and edges. A property key must be created prior to adding it to either type of element. Allowed characters for the name are alphabetical or underscore. The data type must be included. A property key can have cardinality specified, single(default) or multiple, properties (meta-properties), and a time-to-live (TTL) to determine the lifecycle of a property.

Multiple cardinality (multi-properties) will be retrieved in graph traversals more slowly than single cardinality properties, because vertices with multi-properties will default to requesting properties individually.

Examples

Create a property key with the name name of Text type.

schema.propertyKey('name').Text().create()

Create a property key with the name num_items of Integer type if the property key doesn’t already exist.

schema.propertyKey('num_items').Int().ifNotExists().create()

Create a property key with the name createDate of Timestamp type with multiple property cardinality.

schema.propertyKey('createDate').Timestamp().multiple().create()

Add a meta-property for a property. The meta-property, first_publication, must exist.

schema.propertyKey('createDate').properties('first_publication').add()

Create a time-to-live (TTL) for a property key of 60 seconds. Setting a TTL will expire all properties inserted with the propertyKey at the set TTL value.

schema.propertyKey('createDate').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 will be affected by the TTL setting. DSE Graph cannot set TTL for an individual vertex or edge.

Check if a property key exists.

schema.propertyKey('name').exists()

Get the schema creation command for a property key using the describe() command.

schema.propertyKey('name').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