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: Label person, partition key person_id has a unique value of 4ce9caf1-25b8-468e-a983-69bad20c017a

  • dseg:/fridge_sensor/45/300/66665/1: Label fridge_sensor, partition keys state_id, city_id, and zipcode_id and clustering key sensor_id, and corresponding values as shown

  • dseg:/meal/lunch/4003: Label meal with partition keys type and meal_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 key person_id has a unique value of 4ce9caf1-25b8-468e-a983-69bad20c017a, followed by incoming partition key recipe_id has a unique value of 2006

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()

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com