Getting 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.
Installation of Gremlin Console
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:
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:
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
More information about using the toy graphs can be found in TinkerPop's tutorial called The Gremlin Console.