Gremlin Language¶
Gremlin is only available via API v1
Gremlin is reachable only through API v1 endpoints. API v1 is planned for deprecation and will be removed in a future release; Gremlin support will go with it. Use Cypher instead, which provides equivalent functionality with better performance and more complete feature support. See Migrating from API v1 for details.
Gremlin is a graph query language, but one that is less declarative than Cypher Language and more focused on letting users specify exactly the traversal they want. The main strength that Gremlin has is that one of its focuses is traversals: instructions for how to walk the graph structure given some starting points.
When API v1 is configured as the default (default-api-version = "v1"), the Exploration UI supports querying nodes in Gremlin or Cypher interchangeably, and quick queries can be defined in Gremlin. With the default setting of "v2", the Exploration UI uses Cypher; Gremlin remains accessible only via direct calls to the /api/v1/query/gremlin* endpoints.
Note
Quine supports only a subset of Gremlin, and uses a custom language parser to do so. It is much faster, but less feature-full than the Gremlin Server application provided in the Tinkerpop package. The source code defining what is supported in Quine's use of Gremlin is found in GremlinParser.scala.
The parts of Gremlin that are implemented are not guaranteed to be compliant. Part of the difficulty here is that some parts of Gremlin were designed to be executed form inside a host language, usually Groovy, and don't extend naturally to remote execution (see for instance this section of the Gremlin manual for some complexities around anonymous functions).
Query Start¶
All supported Gremlin queries begin in one of two ways:
g.This "g" refers to the "graph" and can take any traversal step following it. This is the primary use case.- Assignment to a variable followed by a semi-colon, then another supported Gremlin query. E.g.:
x = 1234; g.V(x)
Expressions¶
idFrom( [values] )- literal value
- list of values:
[value,value,…]
Predicates¶
eqneqwithinregex
Traversal Steps¶
v()orV()v(id)orV(id)whereidis one or more node IDs.recentVhashasNothasLabelhasIdeqToVaroutoutLimitininLimitbothbothLimitoutEoutELimitinEinELimitbothEbothELimitoutVinVbothVvaluesvalueMapdedupasselectlimitidstrIdunrollPathcountgroupCountnotwhereorandisunion