vertexLabel
How to create a vertex label.
Synopsis
schema.vertexLabel('vertexLabel').
[ partitionKey(propertyKey [, ... ]) ].
[ clusteringKey(propertyKey[, ...]) ].
[ ttl ].
[ ifNotExists() ].
[ index ].
[ properties(property, ...).[ add() | drop() ]].
[ cache().properties() | cache().bothE() ].
[create() | drop() | describe() | exists() ]
Description
- partitionKey
-
Specify a vertex label partition key. The value consists of one or more previously created property keys, with multiple property keys forming a composite partition key. The partitionKey and clusteringKey are used to specify a user-defined vertex id, identifying the partition storage location and order within the partition, respectively.
- clusteringKey
-
Specify whether a vertex label can have any clustering keys. A clustering key can consist of one or more previously created property keys that specify how data will be stored within a partition.
- ttl
-
Set a time-to-live for a vertex label.
- ifNotExists
- Creating a vertex label can check for lack of current existence with
ifNotExists()
before creating a new vertex label. - index
-
Set an index for a vertex label.
- properties
- Properties can be added to 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.
Examples
meal_plan
:schema.vertexLabel('meal_plan').create()
ingredient
if the vertex label doesn't already
exist:schema.vertexLabel('ingredient').ifNotExists().create()
schema.vertexLabel('person').properties('nationality', 'age').add()
For indexes, see each index entry (edge index, property index, vertex index) in the Schema API.
person
vertices up to an hour (3600
seconds):schema.vertexLabel('person').cache().properties().ttl(3600).add()
Enabling
property cache causes index queries to use IndexCache for the specified vertex label.made
edges for person
vertices up to a minute (60
seconds):schema.vertexLabel('person').cache().bothE('made').ttl(60).add()
schema.vertexLabel('shopping_list').ttl(60).create()
schema.vertexLabel('meal_plan').exists()
describe()
command:schema.vertexLabel('person').describe()
drop()
command:schema.vertexLabel('shopping_list').drop()
nationality
from a vertex label:
schema.vertexLabel('person').properties('nationality').drop()
sensor_id
as a partition
key.schema().vertexLabel('fridge_sensor').partitionKey('sensor_id').create()
city_id
and clustering key
sensor_id
.schema().vertexLabel('fridge_sensor').partitionKey('city_id').clusteringKey('sensor_id').create()
graph.addVertex(label, 'fridge_sensor', 'city_id', 100, 'sensor_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
city_id
and sensor_id
as a
composite partition key.
schema().vertexLabel('fridge_sensor').partitionKey('city_id', 'sensor_id').create()