Looking for gremlin Answers? Try Ask4KnowledgeBase
Looking for gremlin Keywords? Try Ask4Keywords

gremlinGetting started with gremlin


Gremlin is the graph traversal language of Apache TinkerPop. Gremlin provides a graph-agnostic way to write queries for any TinkerPop-enabled graph database or graph processor. Gremlin provides support for both imperative and declarative style traversals and can even allow for writing queries that are hybrids of both.


VersionRelease Date

Installation of Gremlin Console

The easiest way to get started with Gremlin is to install the Gremlin Console. The Gremlin Console is a REPL that allows immediate feedback on the results of Gremlin traversals.

As a prerequisite, Java 8 is required for the Gremlin Console to run. Ensure that it is installed prior to moving forward with the following steps.

Download the console, unpackage it and start it:

$ unzip apache-gremlin-console-x.y.z-bin.zip
$ cd apache-gremlin-console-x.y.z
$ bin/gremlin.sh

         (o o)
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph

If on Windows, there is an included gremlin.bat file that can be used to start the console.

To learn more about Gremlin Console, please read TinkerPop's tutorial which discusses it's usage in greater detail.

Using the Toy Graphs

The TinkerPop "toy graphs" make it possible to quickly try out some basic features of Gremlin. These graphs are pre-built and packaged with the Gremlin Console. The most commonly used "toy graphs" are "Modern" and "The Crew". When asking questions on StackOverflow or the Gremlin Users mailing list it is often useful to frame questions in the context of these graphs as they can help questions get answered quickly and easily by the community.

Both the Modern and Crew graph can be constructed with the TinekrFactory , which will construct an in-memory TinkerGraph with the data pre-loaded:

gremlin> graph = TinkerFactory.createModern()
==>tinkergraph[vertices:6 edges:6]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V()

Note the conventions in the above code. The Graph instance is typically called "graph" and then to execute traversals (i.e. queries) one creates a TraversalSource from that Graph called "g". Then, the query g.V() executes a traversal that gets a list of all the vertices in "g".

To create "The Crew" graph, which features meta/multi-properties, use TinkerFactory.createTheCrew() .

More information about using the toy graphs can be found in TinkerPop's tutorial called The Gremlin Console.