Apache TinkerPop


Apache TinkerPop

Join the community to ask questions about Apache TinkerPop and get answers from other members.

Join Server

Can I name the result of an anonymous traversal without moving the traverser?

I can currently do the following: ``` Graph graph = TinkerFactory.createModern(); ...
You could perhaps play around with store ``` gremlin> g.V().hasLabel("person"). ......1> has("name", "josh"). ......2> where(__.out().has("name", "ripple").store('a'))....

Can GraphBinary be used to save a graph to file?

Can GraphBinary be used to save graph in a file. Any example is welcome.
I think you would have to use GraphSON the way @danielcraig23 described. Or if using Java, Gryo. We simply never created GraphBinaryGraphWriter implementations because GraphBinary was built for network serialization. I suppose it could be used that way, but no one has ever really made a request to do that.
VKValentyn Kahamlyk10/10/2023

How to get cardinality of property?

I have a multi property and I want to find out its cardinality. How can I do that? valueMap/elementMap don't help...
TinkerPop really doesn't know, so it can't tell you the answer. It has no notion of schema. You as the user have to know and adjusting your Gremlin accordingly in your application layer. The best that we have internally (and maybe for embedded use cases) is VertexFeatures.getCardinality(String) which, if implemented by the provider, will tell you a hint at the cardinality. https://github.com/apache/tinkerpop/blob/1e3c881d9f157167b53f431898e6d1ee40429cd0/gremlin-core/src/main/java/org/apache/t...

inverted regex search

Hey, In my vertices I store escaped regexp statements as labels (e.g: 'wh.' which in theory should match the string "why"). I have an input string such as for example 'why'. This input parameter string string should be matched against the regexps stored in the vertices and the matching vertices should be returned. What would be the way to do that? Is there a more optimal query to that than let's say ''' g.label().filter(regex(label()).matches('why')) ''''...
Sorry, I didn't see this question for some reason. I can't think of a way to do what you want to do. regex is a P which is a form of predicate and P cannot take dynamic values. The only way you could do it is to use a lambda/closure as you already tried to do: ``` gremlin> import java.util.regex.Pattern ==>java.util.regex.Pattern gremlin> g = TinkerGraph.open().traversal()...

Debug message spam from tinkerpop server 3.7

Right now, when connecting to my local tinkerpop server, I am getting incredible amounts of debug log spam, and I am unsure how to configure to reduce it. The docs talk about being able to set environment variables in a bin/gremlin-server.conf next to the server start script, and I have done that, but they only list valid environment variables no examples of usage. If I treat it like a .env file, I would expect something like DEBUG=False to do the trick but this does not seem to be the case? It may be relevant that I am running this on windows, and therefore using the .bat and not the .sh. I feel like I am missing something obvious, but I am not sure what I should be looking at next?...
I have configured the logback.xml in both the server and console directories to ERROR level and verified it suppresses all output from both at launch. but as soon as I connect to the server, that seems to be overridden. However, I have found a workable solution running everything in docker(identical configs across the board), so I am going to chalk this up to windows weirdness and leave it. thanks for taking the time to look at this though....

Should by() Modulator Work For More Types?

This works. gremlin> g.V().out().out().path().by("name") ==>[marko,josh,ripple] ==>[marko,josh,lop] ...
This is a bug and I know whats' wrong. I will fix it for 3.7.1. Please create a JIRA for it.

InProcess GraphDB with Gremlin Support? (C# or NodeJS)

Hello, is there any in process GraphDB out there in the world? Best would be c# or NodeJS and not Java 😉 questions <:provider_neptune:1131661367972221059>...
Not that I know of for NodeJS. The best I've found is to either spin up a container (I believe there is a docker image for each version) or run gremlin server using a script before the code execution. In my case I needed to run unit-test on Neptune so I used the script method. I've seen this request a couple of times, if you're also interested I can try to make it open source...

Easiest Way to Get List Cardinality Properties As a List?

What is the easiest way to retrieve the vertex properties that have list cardinality back as a list in the traversal stream? The values() step seems to unfold the list. For example, using the "the crew" example graph. `gremlin> g.V().valueMap() ==>[name:[marko],location:[san diego,santa cruz,brussels,santa fe]]...
after some reflection i sense that the question you are asking is actually the answer in the first place. i assume this is in relation to string/list functions, in which case use of valueMap() as you did and group() would be the the primary ways you'd end with a List where the former is the most likely one for the average case where you might want to do like:
but instead, as there is no local have to do:...
VCCvuon cham chi9/27/2023

filter lambda in remote console

hi all, i’m trying to do filter on remote console to neptune server but keep getting MalformedQueryException for query like g.V().filter { it.get().label() == ‘person’ }. Advices are appreciated. TIA
Neptune does not support closures/lambdas: https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html#feature-gremlin-differences-lambda you would have to use pure Gremlin steps, thus g.V().hasLabel('person')

within() and case insensitive

I need to check if a property of a node is in a list of values. How can I do that in a case insensitive manner? has('name',within('vadas','josh')) (+ case_insensitive?) I can do that naughty step : ...
TextP.regex can be used, something like g.V().has("name", TextP.regex("(?i)^(vadas|josh)$"))...

project("p").by(__.values("a", "b") Only Outputs Single Property, Bug or Expected?

I am curious why this does not behave in the way I expected. Not a problem - solution question. I created the following Gremlin: ` g.E()....
i think the more specific way to answer this question is to say that by() modulators only grab the first item in the traversal provided to it so if you want all of them you need to provide your own reducing operator to convert all the items into a single one. typically this is done with fold(): by(__.values("localId", "uuid").fold())e...

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()
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)...

@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...
The two ScriptEngine implementations are not meant to have complete feature parity. GremlinLangScriptEngine does not process arbitrary code. It only processes Gremlin, which I tend to think is a good thing compared to GremlinGroovyScriptEngine which will run any arbitrary code and is therefore a bit of a security risk. That said there is some untangling to do in Gremlin Server, ScriptEngines and the grammar and that's the main reason TinkerPop has not yet promoted GremlinLangScriptEngine over its groovy counterpart despite it being more secure and generally more performant than both groovy and bytecode. This is the reason why we don't have much documentation on it. I believe that you should be able to process Gremlin that originated from a DSL in the GremlinLangScriptEngine but you couldn't do it in the fashion you can with groovy. To understand how it's worth noting that any DSL step is really just a compositions of standard Gremlin steps. in other words, a DSL step like: g.persons() might really just compose as: g.V().hasLabel('person')...

RepeatStep does not appear to respect barriers

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

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"). property(id, select("myID"))....

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() ==>{} ==>{} ==>{oncall_roster=[oncall_schedule]} ...

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:...
On the other hand, @dbns97_61020 's issue is that we have the exact same PropertiesStep under the same traversal. I am not sure if we need to improve that part, a user might need to specify the Step they want by its index, or use == and compare by reference (you need the reference of the exact object in advance though). You may also rely on Step ID to identify some Step in such case as well....