partitionKey - clusteringKey

How to define a partition key or clustering key.

Synopsis

partitionKey('id_name').[ clusteringKey(('id_name') ]

Description

partitionKey and clusteringKey are used to specify a user-defined vertex id in conjunction with vertexLabel. The partitionKey sets a partition key. A composite partition key can also be set. by chaining partitionKey items. The clusteringKey sets a clustering key. The property keys used must be created prior to use.

Examples

Create a propertyKey city_id.
schema.propertyKey('city_id').Int().create()
Create a vertexLabel using sensor_id as a partitioning key.
schema().vertexLabel('FridgeSensor').partitionKey('sensor_id').create()
Create a vertex label with a custom partitioning key city_id and clustering key sensor_id.
schema().vertexLabel('FridgeSensor').partitionKey('city_id').clusteringKey('sensor_id').create()
Create a vertex using city_id as a partitioning key and sensor_id as a clustering key. The property key sensor_id must already exist and be an UUID.
graph.addVertex(label, 'FridgeSensor', 'city_id', 100, 'sensor_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
Create a vertexLabel using city_id and sensor_id as a composite partitioning key.
schema().vertexLabel('FridgeSensor').partitionKey('city_id', 'sensor_id').create()