# Quickstart: Aerospike Graph

This quickstart walks you through:

-   Setting up Aerospike Graph locally
-   Loading a sample dataset
-   Running Gremlin queries with the Gremlin Console

## Prerequisites

Install the following dependencies before proceeding:

-   [Docker](https://www.docker.com/)
-   [Java SE 17](https://www.oracle.com/java/technologies/downloads/archive/) for the Gremlin Console
-   [Python 3.10](https://www.python.org/downloads/) for the sample app

If you manage multiple Java versions, temporarily [change the PATH system variable](https://www.java.com/en/download/help/path.html) so the Java SE 17 `bin` directory is first on the PATH.

## Start Aerospike Graph in Docker

Using the preconfigured [Aerospike Graph GitHub repository](https://github.com/aerospike/aerospike-graph), we’ll quickly get up and running with a one-node Aerospike Graph Service (AGS) instance and a one-node Aerospike Database cluster.

1.  Clone the Aerospike Graph repository and navigate to the new directory.
    
    Terminal window
    
    ```bash
    git clone https://github.com/aerospike/aerospike-graph.git
    
    cd aerospike-graph
    ```
    
2.  Start the Docker Compose stack.
    
    Terminal window
    
    ```bash
    docker compose up -d
    ```
    
    Terminal window
    
    ```bash
    ✔ Network asgraph_net                Created
    
     ✔ Container aerospike-db             Healthy
    
     ✔ Container asgraph-zipkin           Healthy
    
     ✔ Container aerospike-graph-service  Started
    ```
    
3.  Verify that Aerospike Graph Service, Zipkin (a [query tracing service](https://aerospike.com/docs/graph/observe/query-tracing/)), and Aerospike Database are running.
    
    Terminal window
    
    ```bash
    docker ps
    ```
    
    Example response
    
    Terminal window
    
    ```bash
    9d5b0cfab45f   aerospike/aerospike-graph-service:latest    "scripts/gremlin-ser…"...
    
    6ca1415981fe   openzipkin/zipkin                           "start-zipkin"...
    
    248a05d9e903   aerospike/aerospike-server-enterprise:7.1   "/usr/bin/as-tini-st…"...
    ```
    
    The output should show three running Docker processes: Aerospike Graph Service, Zipkin, and Aerospike Database.
    

## Fetch the air-routes dataset

The [Air Routes sample dataset](https://github.com/krlawrence/graph/tree/master/sample-data) by Kelvin Lawrence is a well-known graph dataset featuring airlines, airports, and the routes between them. Its real-world graph structure provides an excellent environment for exploring core Gremlin query patterns.

1.  Create an `air-routes` directory at the root of the repository with `edges` and `vertices` subdirectories.
    
    Terminal window
    
    ```bash
    mkdir -p air-routes/edges air-routes/vertices
    ```
    
2.  Download the Air Routes CSV files into the new directories.
    
    Terminal window
    
    ```bash
    curl -L -o air-routes/edges/air-routes-latest-edges.csv https://raw.githubusercontent.com/krlawrence/graph/refs/heads/master/sample-data/air-routes-latest-edges.csv
    
    curl -L -o air-routes/vertices/air-routes-latest-nodes.csv https://raw.githubusercontent.com/krlawrence/graph/refs/heads/master/sample-data/air-routes-latest-nodes.csv
    ```
    

## Install the Gremlin Console

[Gremlin Console](https://tinkerpop.apache.org/docs/current/tutorials/the-gremlin-console/) is a command-line interface for issuing Gremlin traversals against your running graph service.

1.  Download and extract the latest Gremlin Console from the Apache TinkerPop downloads
    
    Terminal window
    
    ```bash
    curl -O https://dlcdn.apache.org/tinkerpop/3.8.0/apache-tinkerpop-gremlin-console-3.8.0-bin.zip && unzip apache-tinkerpop-gremlin-console-3.8.0-bin.zip && rm apache-tinkerpop-gremlin-console-3.8.0-bin.zip
    ```
    
2.  Start the console from the extracted directory.
    
    Terminal window
    
    ```bash
    apache-tinkerpop-gremlin-console-3.8.0/bin/gremlin.sh
    ```
    
3.  Connect to the Aerospike Graph Service instance.
    
    ```groovy
    g = traversal().withRemote(DriverRemoteConnection.using("localhost", 8182, "g"));
    ```
    
    Example response
    
    ```groovy
    graphtraversalsource[emptygraph[empty], standard]
    ```
    

## Bulk load the dataset

Aerospike Graph provides a bulk loader call step that ingests vertex and edge CSV files directly from mounted storage.

1.  Kick off the bulk loader from the Gremlin Console.
    
    ```groovy
    g.with("evaluationTimeout", 30000) \
    
    .call("aerospike.graphloader.admin.bulk-load.load") \
    
    .with("aerospike.graphloader.vertices", "/data/air-routes/vertices") \
    
    .with("aerospike.graphloader.edges", "/data/air-routes/edges").next()
    ```
    
    Example response
    
    ```groovy
    ==>Bulk load started successfully. Use the g.call("aerospike.graphloader.admin.bulk-load.status") command to get the status of the job.
    ```
    
2.  Poll the job until it completes.
    
    ```groovy
    g.call("aerospike.graphloader.admin.bulk-load.status").next()
    ```
    
    Example response
    
    ```groovy
    ==>duplicate-vertex-ids=0
    
    ==>bad-edges=0
    
    ==>step=done
    
    ==>bad-entries=0
    
    ==>complete=true
    
    ==>status=success
    ```
    

## Explore the graph

Use the Gremlin Console to experiment with Gremlin queries in AGS, explore vertices, traverse edges, and gain hands-on experience with basic graph traversal patterns to better understand the loaded data model.

1.  Find the airport with code `DFW`.
    
    ```groovy
    g.V().has('code','DFW')
    ```
    
    Example response
    
    ```groovy
    v[8]
    ```
    
2.  Count the number of airports in the graph.
    
    ```groovy
    g.V().hasLabel('airport').count()
    ```
    
    Example response
    
    ```groovy
    3504
    ```
    
3.  Count the flights departing from `SFO`.
    
    ```groovy
    g.V().has('code','SFO').outE().count()
    ```
    
    Example response
    
    ```groovy
    157
    ```
    
4.  List cities with routes longer than 4000 miles.
    
    ```groovy
    g.E().has("dist", P.gt(4000L)).inV().values("city").dedup()
    ```
    
    Example response
    
    ```groovy
    Fortaleza
    
    Cayo Largo del Sur
    
    Varadero
    
    Holguin
    
    Puerto Plata
    ```
    
5.  Find U.S. airports reached from London Heathrow (`LHR`).
    
    ```groovy
    g.V().has('country','US').where(in('route').has('code','LHR')).values('code').toList()
    ```
    
    Example response
    
    ```groovy
    IAH
    
    CHS
    
    ORD
    
    EWR
    
    BWI
    
    PIT
    ```
    
6.  Get unique locations accessible from `SFO` within two hops.
    
    ```groovy
    g.V().has("code", "SFO").out().out().dedup().fold().project("totalAirportCountFromSFO",    "USAirportCountFromSFO").by(__.unfold().count()).by(__.unfold().has("country", "US").count())
    ```
    
    Example response
    
    ```groovy
    [totalAirportCountFromSFO:1904,USAirportCountFromSFO:455]
    ```
    

## Finish up

Exit the Gremlin Console and stop the Docker services when you are finished.

1.  Exit the Gremlin Console.
    
    Terminal window
    
    ```bash
    :exit
    ```
    
2.  Navigate back to the `aerospike-graph` root directory.
    
3.  Shut down the three running Docker processes.
    
    Terminal window
    
    ```bash
    docker compose down
    ```
    

## Done!

You have now set up Aerospike Graph locally, explored the Python example app, loaded the Air Routes dataset, and queried it with Gremlin. Next, try visualizing your data with G.V() and learn more about the Gremlin IDE on the [Visualization with G.V()](https://aerospike.com/docs/graph/observe/gdotv) page.