Apache TinkerPop

AT

Apache TinkerPop

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

Join Server

Community questions

Ffaraz03339/20/2023

Use of by()

Can somebody explain the usecase of by() function in gremlin in very simple language.
Solution:
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()
==>[v[1]:1,v[2]:1,v[3]:1,v[4]:1,v[5]:1,v[6]:1]

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)
==>[software:2,person:4]

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).
J3j9/15/2023

@GremlinDSL support in the GremlinLangScriptEngine

Hi,

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.

https://github.com/ArcadeData/arcadedb/pull/1239

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...
LLyndon9/13/2023

RepeatStep does not appear to respect barriers

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

g.V(<ids>).repeat(out()).until(out().count().is(0)).toList()


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:
g.V(<ids>).repeat(barrier(10).out()).times(2).toList()

and then put...
Dduffrey9/11/2023

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"]]).
addV("MyVertex").as("newVertex").
pr...
Hharsh19919/5/2023

Does Gremlin support API for CRUD operations?

Currently using g.V() for read and g.addV() for write.
Ddmcdev_410749/5/2023

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,
Mmihirshh8/31/2023

Filter out empty results

gremlin> g.V().hasLabel('metadata').valueMap()
==>{}
==>{}
==>{oncall_roster=[oncall_schedule]}

How to skip or ignore the {} empty results in query
Bbillmanh8/31/2023

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?
Ddbns97_610208/31/2023

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:
`traversal.g...
Bbillmanh8/26/2023

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...
J.johnallen8/25/2023

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

g.V(vertexId).addE(“linked_to”).from(__.V(vertex2,vertex3))

Thanks for any help. This has stumped me for three days 😂
Ddanielcraig238/24/2023

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()
Tthakkarmeet8/23/2023

Trying to update a property value based on another property

I have a query that looks something like the following

g.V('9999').hasLabel('someLabel').properties('PropertyName').hasId('1234').property('currentDate',12/12/2023).property('previousDate',10/10/2023)

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...
LLyndon8/23/2023

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").
                    by(__.unfold().values("...").dedup().count()).
                    by(__.unfold().
                           repeat( __.in()).
                                    emit(__.<etc>))
                    

The problem is because of the fold it loses the t...
Jjimidle8/22/2023

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").
        ValueMap().With(gremlingo.WithOptions.Tokens).
        Map(__.Unfold()).
        Group().By(Keys).
        By(__.Choose(__.Select(Values).Count(Local).Is(1),
            __.Select(Values).Unfold(),
            __.Select(Values))).
        Unfold().
        ToList()


However, what I want is for the properites in Neptune that have...
Jjimidle8/17/2023

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...
Ccriminosis8/16/2023

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...
Ccinterloper8/16/2023

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?
Nnathimble_074518/10/2023

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 = (
    g.V(vertex)
    .property("~supernode", True)
    .property("foo", "bar")
    .property("baz", "biz")
    .explain()
    .next()
)

when the explain ste...