Apache TinkerPop


Apache TinkerPop

Apache TinkerPop is an open source graph computing framework and the home of the Gremlin graph query language.

Join Server

Community questions


Use of by()

Can somebody explain the usecase of by() function in gremlin in very simple language.
by() is a step modulator, meaning it modifies the step it is being applied to in some way by giving it some additional instruction. an easy example to see this with is groupCount():
gremlin> g.V().groupCount()

Calling groupCount() without modulation implies the default behavior of grouping on the incoming traverser (i.e. the current Vertex). Each Vertex is simply counted once as a result as they are each unique entities. If we want to change that grouping behavior, we modulate that step with by(), like:
gremlin> g.V().groupCount().by(label)

Now we're saying, go ahead and group count the vertices but use the label of the Vertex for the grouping. it is important to note that what by() does is dependent on the step to which it is applied (and that on its own it really doesn't do anything at all).

@GremlinDSL support in the GremlinLangScriptEngine


I recently sent a pull-request into the github ArcadeDB repository to add support binding custom TraversalSources to the embedded graph bound in the script engine. ArcadeDb has modes to support both the GremlinLangScriptEngine and the GremlinGroovyScriptEngine.


I realized today that the GremlinLangScriptEngine went untested, and after trying to add a test I've come to question whether there is any support at all for DSLs in the Gremli...

RepeatStep does not appear to respect barriers

I was digging into some traversal performance and had something similar to the following:


For the graph implementation in question, out() is implemented on top of a CollectingBarrierStep.

I noticed that that fact is not respected by the repeat and it only gets 1 item at a time, i.e no aggregation.

I removed my strategy and changed the query to:

and then put...

Trying to find a Vertex using a variable injected earlier in the traversal

I am trying to add a series of vertices and edges to an existing graph. The newly created Vertex will be the to Vertex. From business logic, I will know the ID of the from Vertex for the new Edge . I am able to create the new Vertex without any issue, but when I am having trouble grabbing the from Vertex to create the edge. Is there a way to do this/what am I doing wrong?

```g.inject(["myID": "2", "parentID": "1", "properties": ["key1":"value1"]]).

Does Gremlin support API for CRUD operations?

Currently using g.V() for read and g.addV() for write.

Individual Vertex per property or Vertex with grouped properties

I'm building an identity graph that also stores User profile data - things like email address, phone number, address, company information, etc. Is there a generally accepted best practice for whether to store those attributes in their own vertex or group them in a vertex? The graph is part of a transactional system that will need to retrieve a complete user profile,

Filter out empty results

gremlin> g.V().hasLabel('metadata').valueMap()

How to skip or ignore the {} empty results in query

Question on running queries in windows env.

I get an error RuntimeError: Event loop is closed, but after troubleshooting I notice that my script ran just fine. It crashed after the script eded. I suppose I was just ignoring it at first, but should I? I'm using asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) . Should I just ignore the error or should I deal with it? if the latter, how?

PropertiesStep.hashcode() not always unique

As background...
We're working with Gremlin (groovy) to write queries against an in memory graph model implemented in java.
I've implemented a custom traversal strategy that will find all PropertiesStep instances in the traversal and prepend a custom step to each one (I could go into more detail but it's not actually relevant to my question).

While implementing the apply method of the strategy I was getting the index of the PropertiesStep instances using the indexOf method:

Trying to run a local version for a test, what is the correct serializer?

Windows machine, local host. I can't find the
Running this, https://github.com/bricaud/gremlin-server but updated the version to apache-tinkerpop-gremlin-server-3.7.0

I had issue with the serializers: section of the gremlin-conf.yaml so I commented out to see if the defaults would work. The docker image loads fine, but then I can't seem to connect to it.

My simple test:
print('Number of nodes {}, number of edges {}.'.format(g.V().count().next(),g.E().count().next()))

My er...

adding edges to multiple vertices at once

Hey all. Working with tinkerpop on Cosmos Gremlin DB which is horrific.

Wondering is there anyway around adding an edge from multiple vertices at the same time?

For example


Thanks for any help. This has stumped me for three days 😂

Does .math() always return a Double?

I have the following query, how can I get the result as a Long instead of a Double? In context, I want this query to be unioned with a set of other numbers which are Longs and then I want to take the .max() of them. But I can't do that if I have a mix of Long and Double

Long tenHours = Long.valueOf(Duration.ofHours(10).toMillis());

g.withSideEffect("tenHours", tenHours).inject(1689570000000L).math("_ + tenHours").next().getClass()

Trying to update a property value based on another property

I have a query that looks something like the following


Using this query when an Id matches the passed value on hasId the data needs to be updated. I'm able to update currentDate & previousDate, which is a meta property, on the following data, however I'd also like to update the 'value' field which is on the same level as the 'id' field. My question i...

Casting issue with Gremlin Java

I wrote the following query and I can't get it to compile, tried a ton of casting but it just isn't happy...

g.V(..).in(..).<some contraints that do not change it from a vertex).
        fold().project("visits", "form").
                           repeat( __.in()).

The problem is because of the fold it loses the t...

valueMap and Multivalues

I was going to use the recipe from @KelvinL 's book to return lists only when the property has multiple values:

l, err := g.G.V(id).HasLabel("geoname").

However, what I want is for the properites in Neptune that have...

AWS Neptune bulk load notifications

I wonder if anyone has knowledge of a way to receive a notification event(s) for bulk loading. Right now, one can poll via the https endpoint, but that would require having a container running somewhere that did this.

I was rather hoping to configure an SNS notification for say status change "LOAD_STARTED"... etc. The JSON given by the https: calls would be fine as having received the notification, I can use the standard calls to retrieve errors and more detailed information etc.

Fairly stan...

VertexProgram filter graph before termination

I have a VertexProgram that operates on vertices of type A and B.

B vertices are "below" A vertices.

The VertexProgram aggregates stuff about the underlying B vertices into their common parent A vertex.

I've successfully done the aggregation, but now I want to filter the A vertices that don't pass a predicate about the aggregated property they've accumulated based on messages from their underlying B vertices.

I was thinking of having a follow-up state machine for the VertexProgram like the S...

Straightforward way to render a force directed graph svg/png

I was wondering if there is a "simple" way in java for me to take a GraphTraversal and render a force directed picture of the graph or subgraph it returns?

Can't do explain() traversal step using Gremlin-Python ..

Hi I just started messing around in gremlin-python this week, so likely to be doing something wrong with g, but as mentioned on twitch, I'm unable to add an explain() step to one of my first traversals.
i start with g a connected graphTraversalSource and perform the following
vertex = g.add_v("my_vertex").next()
vertex = (
    .property("~supernode", True)
    .property("foo", "bar")
    .property("baz", "biz")

when the explain ste...