Creating a graph in the Gremlin console

DataStax Studio creates a graph automatically for each connection that is created. In Gremlin console, a graph must be manually created. In addition to creating the graph, a graph traversal must be aliased to the graph in order to run queries.

  1. Start the Gremlin console.

  2. Create a simple graph with default settings to hold the data.

    gremlin> system.graph('food').create()
    $ ==>null

    This command is not available if a graph traversal is aliased with the :remote config alias g some_graph.g command. In order to access the system command, reset the alias with :remote config alias reset

  3. Create a graph with non-default replication, systemReplication, and configuration settings:

      replication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3 }").
      systemReplication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3 }").

    For graphs created in multi-datacenter clusters, the DSE database settings must use NetworkTopologyStrategy and a replication factor greater than one. If the graph is created with a replication setting of SimpleStrategy and a replication factor of 1, the graph data will be stored across the multiple datacenters rather than localizing the data in the graph datacenter.

    + The default replication strategy for a multi-datacenter graph is NetworkTopologyStrategy, whereas for a single datacenter, the replication strategy will default to SimpleStrategy. The number of nodes will determine the default replication factor:

    Nodes per datacenter and default replication factor
    number of nodes per datacenter graph_name replication factor

    graph_name_system replication factor


    number of nodes per datacenter

    number of nodes per datacenter

    greater than 3


  4. On the remote Gremlin Server, set the alias for the graph traversal g to the graph traversal specified in food. To run traversals, the graph traversal must be aliased to a graph.

    gremlin> :remote config alias g food.g
    $ ==>g=food.g
  5. A list of all graphs can be retrieved with the following command:

    gremlin> system.graphs()
    $ ==> food
    $ ==> test

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,