propertyKey

How to create a property key.

Synopsis

propertyKey('name').
  type().
  [ single() | multiple() ].
  [ properties(metadata_property).[ add() | drop()] ].
  [ ttl ].
  [ ifNotExists() ].
  [ create() | add() | | drop() | 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. The data type must be included.
Note: Naming convention used to allow nearly unrestricted Unicode. Now the only allowed characters are [a-zA-Z0-9], underscore, hyphen, and period.
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.
CAUTION: 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.
type

Specify property type.

single, multiple

Specify whether a property can have single or multiple values.

properties
Properties can be added to properties, called meta-properties. Meta-properties can also be dropped from a property key. Allowed characters for the name are alphabetical or underscore.
ttl

Set a time-to-live for a property.

ifNotExists
Creating a property can check for lack of current existence with ifNotExists() before creating a new property key.

Examples

Create a property key with the name difficulty of Text type to describe a recipe's level of expertise:
schema.propertyKey('difficulty').Text().create()
Note: Naming convention used to allow nearly unrestricted Unicode. Now the only allowed characters are [a-zA-Z0-9], underscore, hyphen, and period.
Create a property key with the name prep_time_in_min of Integer type if the property key doesn't already exist:
schema.propertyKey('prep_time_in_min').Int().ifNotExists().create()
Create a property key with the name make_date of Date type with multiple property cardinality:
schema.propertyKey('make_date').Date().multiple().create()
Add a meta-property for a property. The meta-property, region, must first be created as a property key.
schema.propertyKey('country').properties('region').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('book_discount').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 property key exists:
schema.propertyKey('difficulty').exists()
Get the schema creation command for a property key using the describe() command:
schema.propertyKey('difficulty').describe()
Remove a property key with the drop() command:
schema.propertyKey('book_discount').drop()
Remove a meta-property region:
schema.propertyKey('country').properties('region').drop()