Apache TinkerPop


Apache TinkerPop

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

Join Server

search for vertices where multiple properties

I need to search for vertices where multiple properties are a certain value. Here is what I am able to come up with. ``` try (TinkerGraph graph = TinkerGraph.open()) {...

repeat and until methods in Javascript Gremlin:

I'm not particularly sure how to use them properly. From my current understanding, repeat() and until() are both instance methods of the GraphTraversal class, but how do I reference any methods within the class body but still refer to the same reference?
const org = await g.V().until((r) => r.hasLabel('')).repeat({...}).path().by('name').next()

const org = await g.V().until((r) => r.hasLabel('')).repeat({...}).path().by('name').next()

I think this section of the documentation will help with imports: https://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript-imports In particular: ``` const = gremlin.process.statics; const org = await g.V().until.hasLabel('b')). repeat(__.in())....

Gremlin driver setup for Amazon Neptune behind a Load balancer

Hi folks, I've been running into issues connecting to Amazon Neptune behind an HAProxy as detailed on https://aws-samples.github.io/aws-dbs-refarch-graph/src/connecting-using-a-load-balancer/ (2nd option) The issue is to do with sending subsequent queries via a graph traversal source where it appears to cause NoHostAvailableExceptions frequently. The interesting part here is that this only happens when a Graph traversal source is reused. I'm using Gremlin driver 3.7.0 in Java....

Gremlin (with Python + Neptune) Out of Memory Error with .toList()[0], .next() Fixes It. But Why?

This is not really a question, but more of a discussions on how internally this would cause an out of memory error. I have the following construct and last night, it resulted in out of memory error. * path_v is a single well defined V. I am expecting it is returning a single V....
DCDragos Ciupureanu11/12/2023

AWS Neptune and gremlin-javascript versions

Hi, I'm using the js gremlin client 3.6.2 with AWS Neptune version and I get the following error when trying to upsert nodes with mergeV() ``` ResponseError: Server error: {"code":"InternalFailureException","requestId":"aa89ee40-74d5-46c1-9ad5-0bc3f2fde5c1","detailedMessage":"null: .option(LinkedHashMap, LinkedHashMap)","message":"null: .option(LinkedHashMap, LinkedHashMap)"} (599)...
That's a strange error because the error seems to indicate that option() is being called with two Map arguments, but your example does not seem to indicate that you are doing that. It's interesting that 3.7.0 "fixes" it because I can't think of any reason why that would matter. Perhaps you could try 3.6.5 to see if there were somehow changes after 3.6.2 that solved this problem? Regarding your more general question of:
My question is: does the version of the javascript client match the version of the server (or should it)? Or should I always strive to use the latest client?
Generally speaking you should follow the version table here https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-client.html - While it is possible that versions outside of those ranges in that table will work with one another, those are the versions that Neptune tests against and that are supported....

Docker Janusgraph Custom ID Values

I'm trying to setup a janusgraph database with custom verex ID values. I have the following docker-compose configuration: ```yaml version: '3.8' services:...
You could do both ``` graph.set-vertex-id=true graph.allow-custom-vid-types=true...
DCDragos Ciupureanu11/8/2023

Reusing connections

Hi, I'm wondering what's the recommended way of using connections to a graph DB. The documentation uses web sockets like so (in javascript) ```...
Connection pooling in Javascript is a bit of an oddity, since the language has mostly been intended for single-threaded purposes (running in a browser). With that, the websocket library native to Javascript hasn't traditionally supported connection pooling natively. In testing we've done within AWS, the Javascript websocket library is by far the most efficient in creating a new connection (single digit milliseconds). Whereas something like Python's implementation can be really expensive (10s of milliseconds, or worse). So maintaining long-lived connections in Javascript is likely not as big of a deal as it is in other runtimes. (My opinion, so take this with a grain of salt). You should really avoid using websockets until you're faced with a use case that would benefit from them. There's a lot of dev overhead in creating and maintaining websocket connections. Websocket connections are also problematic in distributed compute implementations (or for high availability) as they act like "sticky sessions". They can also cause problems with load balancing logic. I would suggest using http requests for as long as you can before relying on the use of websockets. There is obviously the tradeoff of serialization when it comes to using Gremlin with http vs websockets, but that is something you should be able to handle once and be done with it....

Can I surpress gremlin console's warnings?

How can I surpress these WARNING messages? I've tried gremlin -l but can't seem to get the syntax right because it seems to have no effect when I do gremlin -l ERROR ``` % gremlin WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/usr/local/apache-tinkerpop-gremlin-console-3.6.2/lib/groovy-2.5.15-indy.jar) to method java.lang.Object.finalize()...
I have found that export JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --illegal-access=deny" produces the following ``` % export JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --illegal-access=deny" % gremlin NOTE: Picked up JDK_JAVA_OPTIONS: --illegal-access=deny...

Sequential IDs in Neptune?

@neptune I'm attempting to implement sequential IDs for the vertices in our AWS Neptune graph. So far, we have added a new property called vertexNumber, which will store the numeric sequential ID for each vertex. Then, before saving a vertex to the database, I run a simple query to retrieve the current highest vertex number, increment it, and store the new vertexNumber to that vertex. Pseudo-code examples found below. ```...
DCDragos Ciupureanu11/3/2023

Gremlin console vs REST API

I'm trying to get a path and the properties of the vertices and the edges for that path by running a gremlin script via REST API in Neptune. The query is simple with some filters on the edges, but the result is different from what gremlin console gives me. For example, the following query returns the path with the type of entities (vertex or edge) but only the label and the ID properties. ``` g.V('efc912d3-6cec-49e2-9717-85625bab5243').inE().outV().path()...
Generally speaking, the GLVs and the Gremlin Console (if sending queries as bytecode and connecting via websockets) will serialize the results back into types that are common to the runtime that you're using for your application.
Queries sent over HTTP will return the response using GraphSON (GraphSONv3, be default with Neptune) which includes all of the extra type information....

Cryptic Neptune Gremlin Error Rate Creeping - What Would You Recommend?

This relates more to do with Neptune usage, nevertheless, it is also related to the Gremlin Query error rate that logs in to the Monitor plot page and also triggers cloud watch alert in our case. Situation: We've noticed a gradual increase in unexplained Gremlin error counts — with a few popping up every several hours....


If anyone is familiar with KubeHound DSL. Can someone explain why Query 1 is different from Query 2. They are both returning values that are very close to eachother but not exact: Query 1 g.V() .hasLabel('Container') .out().emit().repeat((...
No description
I figured it out, I've attached the fixed query 1
No description

Help with visualizing in the graph-notebook

I am trying to visualize a graph in the graph-notebook but no matter what I do I cannot get it to be correct. So I have a very simple graph that has like 6 vertices, connected with maybe 8 edges, and I want to just visualize that graph with the labels of the vertices and edges on the visualization and the properties available if you select the details. I have tried may variations of g.V().out().path / g.V().outE().inV().path() with elementMap() before path, using path().by(elementMap()), as well as trying from g.E() and other things. Nothing seems to work, randomly edges are missing labels, or an exta edge is added to each vertex that just goes to itself. ...
Found this https://github.com/aws/graph-notebook/blob/c357870d2a5bce88c986fa114b613ec72ce065f7/src/graph_notebook/notebooks/02-Visualization/Grouping-and-Appearance-Customization-Gremlin.ipynb#L23 and ended up getting a solution with ``` %%gremlin -p v,oute,inv -l 30 g.V().outE().inV().path().by(elementMap())...
DCDragos Ciupureanu10/27/2023

Gremlin browser code editor

Hi, I'm looking for a code editor like monaco https://microsoft.github.io/monaco-editor/ to embed in my browser app that supports Gremlin (even very basic completion, etc.). Monaco doesn't have this out of the box and I was wondering if there is one out there?
I can definitely chime in but the short answer is no - I'm actually planning to switch to Monaco in G.V(), best answer I can provide is that there are plenty guides available out there on how to integrate Monaco with an ANTLR grammar to provide both syntax error detection and editor suggestions (with the added use of antlr4-c3 on npm). A quick google search of monaco antlr4 should give you a step by step guide on all that. That being said if you want a fully featured Gremlin query editor you're not gonna find anything better than G.V() wink wink...

Connecting to local gremlin server with websocket address

Hello everyone. I'm looking for help with a client app written in Java that uses Tinkerpop Gremlin to interact with a Janusgraph instance. When developing new features, I run a local Janusgraph with a Gremlin server at localhost. I'm trying demonstrate that I can take a websocket url and establish a connection using that URL. I believe that the default websocket address for a local Gremlin server is ws:// I'm trying to use a Cluster to create the connection and obtain a GraphTraversalSource. Here's what I'm trying. Cluster cluster = Cluster.build("ws://").create(); GraphTraversalSource g = AnonymousTraversalSource.traversal().withRemote(DriverRemoteConnection.using(cluster)); ...
By default it will connect via websocket so you can try ``` Cluster cluster = Cluster.build("localhost"). path("/gremlin"). create();...

Clarification on Kerberos configuration for Gremlin Driver

I'm a little bit unclear on the role of the JAAS configuration file for the Gremlin client in the context of the gremlin-driver (rather than just the GremlinConsole). Looking at https://tinkerpop.apache.org/docs/current/reference/#krb5authenticator Is the naming convention around the jaasEntry name at all of relevance or can any gremlin-driver assume the existence of a GremlinConsole jaas entry? I'm assuming the mapping here between jaasEntry name and gremlin-driver configuration is done by setting the jaasEntry value on the ClusterBuilder but just looking for confirmation on that!...

Gremlin Driver and frequently changing servers

In a containerised environment, hosts are frequently replaced and their IP address can change several times a day. As far as I can tell, Gremlin Driver was designed for long-lived hosts given that: (1) Contact Points are resolved on startup and a connection pool is assigned to them at that time - this makes varying contact points over time not possible I think? (2) Unavailable hosts are retried but the list of hosts is not refreshed - wouldn't it make more sense to give up on hosts after a few retries and refresh the list of contact points?...
yes, this is a bit of an issue in some cases like the one you describe. a similar issue occurs for Neptune where it would be helpful if the drivers knew the cluster topology. you're basically left to periodically recreate the Cluster object and updating the contact points. Neptune has a special client that wraps the TinkerPop driver to do just that: https://aws.amazon.com/blogs/database/load-balance-graph-queries-using-the-amazon-neptune-gremlin-client/ i've always thought it would be nice if...

Global Search

Is there a way where i can scan all the vertex or edge properties that match a given keyword in gremlin. For ex : g.V().has('name','John') ...
you could do: ``` // 3.7.0+ gremlin> g.union(V(), E()).has('name','josh') ==>v[4]...
DCDragos Ciupureanu10/19/2023

GraphSON mapper

Hi, I'm trying to ingest some data into AWS Neptune and due to its size I'm forced to use a bulk data importer https://tinkerpop.apache.org/docs/current/dev/io/#graphson-3d0 (unless there's a bulk-insert functionality straight from Gremlin - I couldn't find this). Looking at the GraphSON schema/docs I see there are some IDs on the edges that I am not sure how/if I need to generate. https://tinkerpop.apache.org/docs/current/dev/io/#graphson-3d0 ...
Do you already have data in GraphSON format? Or do you just need to use a bulk importer? If the latter, Neptune has it's own bulk load feature: https://docs.aws.amazon.com/neptune/latest/userguide/bulk-load.html

.drop() behavior confussion

I have a basic java app and I'm learning hot to send gremlin queries to a JanusGraph from that java app. I just played around with mkaing some nodes, but the .drop() method is not removing them all like I expected. What am I missing in this context?
No description
This issue is addressed in lots of places but you probably just haven't come across them yet. You're missing a terminal step after the drop(). The terminal step actually executes the traversal...drop() is not such a step. You would likely use iterate() in this case as your terminal step. https://tinkerpop.apache.org/docs/current/reference/#terminal-steps
No description