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 😂
J
JohnAllen234d ago
To give a little more insight into what I am trying to do. Let’s say we have a db g.addV(“user”).property(“name”,”one”).property(“id“,”1”) g.addV(“user”).property(“name”,”two”).property(“id“,”2”) g.addV(“job”).property(“name”,”three”).property(“id“,”3”) What I want to do is add user one and two to the job like this g.V(“1”,”2”).addE(“works_at).to(__.V(“3”)) But it doesn’t seem to work
S
spmallette234d ago
if g.V("1","2") returns two vertices, and V("3") returns one vertex then you should get two edges created. if your example there is literally what you are doing then the problem is likely that none of those are returning any vertices at all. you've added a property called "id" but that doesn't refer to the unique identifier for the vertex. if you want that then you need to use T.id as in property(T.id, "1"). V("1") will then return a vertex in that case.
J
JohnAllen233d ago
Thanks for the reply. In MS’s Cosmos implementation of tinkerpop we can use .property(“id”,X) to set the id of the vertex to X. g.V(X) will return the vertex I expect. g.V(X,Y) returns two vertices… So I should be able to do what I am trying to do. Can’t work this out.. I think it’s something to do with MS’s janky tinkerpop version
S
spmallette233d ago
@KelvinL there's an interesting @cosmosdb difference I wasn't aware of ☝️ Well, @.johnallen perhaps it is something to do with the use of to(V("3")) . I presume that CosmosDB let's you do:
g.V("1").as("1").
V("2").as("2").
V("3").as("3").
addE("works_at").from("1").to("3").
addE("works_at").from("2").to("3")
g.V("1").as("1").
V("2").as("2").
V("3").as("3").
addE("works_at").from("1").to("3").
addE("works_at").from("2").to("3")
it's not nice but it's one query at least
J
JohnAllen231d ago
@spmallette thanks I will try that when I get back from vacation. Will be interesting to see the executionProfile as execution time is a real concern for this query. Will update regardless
Want results from more Discord servers?
Add your server
More Posts
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 wTrying to update a property value based on another propertyI have a query that looks something like the following g.V('9999').hasLabel('someLabel').propertiesCasting issue with Gremlin JavaI wrote the following query and I can't get it to compile, tried a ton of casting but it just isn't valueMap and MultivaluesI was going to use the recipe from @KelvinL 's book to return lists only when the property has multiAWS Neptune bulk load notificationsI wonder if anyone has knowledge of a way to receive a notification event(s) for bulk loading. RightVertexProgram filter graph before terminationI have a VertexProgram that operates on vertices of type A and B. B vertices are "below" A verticesStraightforward way to render a force directed graph svg/pngI was wondering if there is a "simple" way in java for me to take a GraphTraversal and render a forcCan'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 Gremlin Query for amount of time and return all results?Is there a way to make gremlin keep running until time elapses then return the results? I have a queHow do I make a ssl connection using only ARN from neptune (AWS)I have a simple connection in my project using remotecon = DriverRemoteConnection(neptune_url) But Can gremlin-server be started via its Java packageI'm considering exposing the G.V() Playground graphs, which runs on TinkerGraph, to the network via Getting Property Out of a Variable in Python Gremlin QueryI've been working on attempting to find a performance way to route from point A to point B. Right nThe Cascading Coalescing - Create a V then Create an E in One ShotI have been struggling with this and perhaps I can ask some expert on how to approach this type of iToolsetHi all, Im in a bit of a dilemma. Want to start using a graphdb for a new application however ik st