Creating a custom vertex id
How and when to create a custom vertex id.
A custom vertex id can be created to replace the standard auto-generated vertex id
that is normally generated for vertices. The use cases for creating a custom vertex
id are:
- When the data stored in DSE Graph is aligned with other data sources, such as other DSE database keyspaces or another database.
- When custom graph partitioning is desired.
Note: Standard auto-generated ids are
deprecated with DSE 6.0. Custom ids
will undergo changes, and specifying vertex ids with
For example, sensor time series data is stored
in the DSE database. In addition to the time series queries to the DSE database,
relationship information about the sensors is desired, such as how the sensors are
networked and where the sensors are located. To load the data into a graph to
explore the relationships, but retain the ability to write an application that
accesses both the time series data and the graph data, custom vertex ids are created
that span across both database models.partitionKey
and clusteringKey
will likely
become the normal method.CAUTION: Keep in mind that if custom vertex ids are used, they must be
globally unique within the graph, or duplicate vertices can potentially be
loaded into a graph. DSE Graph does not verify the custom vertex ids. Standard
auto-generated vertex ids are guaranteed to be unique.
Procedure
-
Create a vertex label with a custom partitioning key
sensor_id
. The property keysensor_id
must exist prior to use in creating the vertex label and cannot be a multiple cardinality property.schema.vertexLabel('FridgeSensor').partitionKey('sensor_id').create()
-
Add a vertex using the vertex label
FridgeSensor
.graph.addVertex(label, 'FridgeSensor','sensor_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66')
-
Create a vertex label with a custom partitioning key
city_id
and clustering keysensor_id
.schema.vertexLabel('FridgeSensor').partitionKey('city_id').clusteringKey('sensor_id').create()
-
Add a vertex using the vertex label
FridgeSensor
with both a partition key and clustering key.graph.addVertex(label, 'FridgeSensor','sensor_id', '60bcae02-f6e5-11e5-9ce9-5e5517507c66', 'city_id', 100)
-
Create a vertex label with a custom composite partition, using both
city_id
andsensor_id
as part of the partitioning key.schema.vertexLabel('FridgeSensor').partitionKey('city_id', 'sensor_id').create()