tutorial gremlin cosmos-db

Getting Started with Gremlin on Azure Cosmos DB

A practical guide to graph databases, the Gremlin query language, and how to use GremlinStudio to explore your data.

GremlinStudio Team ·

What is a Graph Database?

A graph database stores data as vertices (nodes) and edges (relationships). Unlike relational databases that use tables, graph databases excel at representing and querying connected data — social networks, recommendation engines, knowledge graphs, and fraud detection systems.

Azure Cosmos DB Gremlin API

Azure Cosmos DB’s Gremlin API provides a fully managed graph database service. It supports the Apache TinkerPop Gremlin query language, giving you a powerful way to traverse and manipulate graph data at scale.

Basic Gremlin Queries

Get All Vertices

g.V().limit(10)

This returns the first 10 vertices in your graph.

Find by Label

g.V().hasLabel('person')

Returns all vertices with the label “person”.

Traverse Relationships

g.V().has('name', 'Alice').both('knows')

Find everyone that Alice knows (in both directions).

Create a Vertex

g.addV('person').property('name', 'Bob').property('age', 30)

Create an Edge

g.V().has('name', 'Alice').addE('knows').to(g.V().has('name', 'Bob'))

Using GremlinStudio

GremlinStudio makes working with these queries much more productive:

  1. Autocomplete suggests Gremlin steps as you type
  2. Graph visualization shows results as interactive nodes and edges
  3. Table view lets you sort and search through results
  4. Debugger helps you understand complex traversals step by step

Next Steps