Vertex and edge ids
DataStax Graph uses URIs as an ID format, being a well-defined format with the encoding of special characters well-known.
The format of the vertex id is dseg:/[vertexLabel]/[pk1Value]/[pkValue2]/[pkValue3]
where pkValue
is either a partition key or a clustering key that is defined as part of the primary key of the vertex label CQL table.
Those partition and clustering keys are defined with partitionBy
and clusterBy
.
Here are some examples of vertex ids:
-
dseg:/person/4ce9caf1-25b8-468e-a983-69bad20c017a
: Labelperson
, partition keyperson_id
has a unique value of4ce9caf1-25b8-468e-a983-69bad20c017a
-
dseg:/fridge_sensor/45/300/66665/1
: Labelfridge_sensor
, partition keysstate_id
,city_id
, andzipcode_id
and clustering keysensor_id
, and corresponding values as shown -
dseg:/meal/lunch/4003
: Labelmeal
with partition keystype
andmeal_id
, and corresponding values as shown.
Vertex ids can be used to identify vertices in graph traversals, and are assigned when vertices are inserted.
DataStax Graph uses URIs as an ID format, being a well-defined format with the encoding of special characters well-known.
The format of the edge id is only special in the ordering of the primary key properties, and follows the pattern dseg:/[outVLabel]-[edgeLabel]-[inVLabel]/[outVPkProperty1]/[outVPkProperty2]/[inVPkProperty1]/[inVPkProperty2]
where pkProperty
is the property of either a partition key or a clustering key that is defined as part of the primary key of a vertex label CQL table.
outVPKProperty
defines the properties for the outgoing vertex label and inVPkProperty
defines the properties for the incoming vertex label.
Those partition and clustering keys are defined with partitionBy
and clusterBy
in the vertex labels.
Here are some examples of vertex ids:
-
dseg:/person-created-recipe/4ce9caf1-25b8-468e-a983-69bad20c017a/2006`
dseg:/person/4ce9caf1-25b8-468e-a983-69bad20c017a-created->dseg:/recipe/2006: Label `person-created-recipe
, outgoing partition keyperson_id
has a unique value of4ce9caf1-25b8-468e-a983-69bad20c017a
, followed by incoming partition keyrecipe_id
has a unique value of2006
Edge ids can be used to identify edges in graph traversals, and are assigned when edges are inserted.
Vertices can be filtered using a hasId()
traversal step and providing a particular user-defined vertex id:
g.V().hasId(['~label':'fridgeSensor', 'stateId':31, 'cityId':100, 'sensorId':1]).valueMap()
A vertex can be queried directly using a user-defined vertex id:
g.V(['~label':'fridgeSensor', 'stateId':31, 'cityId':100, 'sensorId':1]).valueMap()