Apache TinkerPop

AT

Apache TinkerPop

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

Join Server
Ppieter11/17/2023

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()) {...
Ttobaseru11/17/2023

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

...
Solution:
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())....
Ggdotv11/15/2023

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

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 1.2.1.0 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)...
Solution:
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....
IIsopropyl911/9/2023

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:...
Solution:
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) ```...
Solution:
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....
Ddanielcraig2311/7/2023

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()...
Solution:
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...
AAndys181411/7/2023

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()...
Solution:
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....
MManabuBeach11/1/2023

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....
GGmane2310/31/2023

kubehound

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
Solution:
I figured it out, I've attached the fixed query 1
No description
LLyndon10/30/2023

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. ...
Solution:
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?
Solution:
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...
Ddw--10/25/2023

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://127.0.0.1:8182/gremlin. 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://127.0.0.1:8182/gremlin").create(); GraphTraversalSource g = AnonymousTraversalSource.traversal().withRemote(DriverRemoteConnection.using(cluster)); ...
Solution:
By default it will connect via websocket so you can try ``` Cluster cluster = Cluster.build("localhost"). path("/gremlin"). create();...
Ggdotv10/24/2023

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!...
Ccdegroc10/24/2023

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?...
Solution:
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...
MMihirshh10/23/2023

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') ...
Solution:
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 ...
Solution:
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
XXonos10/16/2023

.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
Solution:
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
Next