gremlin Getting started with gremlin

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

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.

Versions

VersionRelease Date
3.2.12016-07-18
3.2.02016-04-08
3.1.32016-07-18
3.1.22016-04-08
3.1.12016-02-08
3.1.02015-11-16

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)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin>
 

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()
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]
 

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.



Got any gremlin Question?