how to add an edge between 2 vertices in different partitions - Azure Cosmos DB Gremlin

Omar Ghoche 0 Reputation points

I am trying to add 2 vertices to different logical partitions, then i want to connect them through an edge, but couldn't find anything online! How to do it?!


Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,496 questions
{count} votes

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 28,462 Reputation points Microsoft Employee

    Hi, @Omar Ghoche Welcome to the Microsoft Q&A platform, thanks for posting the question

    When you create your Gremlin API graph you define a partition key path. The value of the partition key for each vertex defines its logical partition. To create vertices in different partitions, you simply define each vertex with a different partition key value. You can then create an edge between the two vertices.

     For example, assuming you have a graph with partition key path /pk, the following two traversals will each create a vertex in a different logical partition:




    This traversal will then select the two existing vertices and create an edge between them:


    Gremlin does not have transactions so it is possible that either of the addV steps may fail or that the sequentially executed traversals may beat the propagation delay for the new graph elements. If it’s possible that this can cause issues in your application, you can read this article on using idempotent queries to ensure the existence the graph elements:

    I hope this information helps