Go syntax for MergeV and docs

186 views
Skip to first unread message

Jim Idle

unread,
May 30, 2023, 3:26:30 AM5/30/23
to Gremlin-users
The Go client seems very good, but i cannot find documentation on the ways to express a lot of things, and the code itself does not give anything away. I wonder if anyone knows of examples or documentation for Go. I see the official documentation does not have Go examples, and the language variant tool does not support Go.

I am trying to work out how to set the label on a vertex using the MergeV() step and the Option OnCreate like this:

g.MergeV(match).
Option(gremlingo.Merge.OnCreate, props).


The match and  props are a map[string]interface and I see that in Groovy and other languages, it seems there is some magic that says [(T.label): "llll", .... or something like that. The vertexes get created, but I have tried different property names ("label", "Label", etc) to try and set the label, with no success. And tried searching the code for anything that looks like it is the equivalent of the Groovy syntax.

So, how do I specify the label in this scenario using the Go client?



Josh Perryman

unread,
May 30, 2023, 3:55:14 PM5/30/23
to Gremlin-users
Looking forward to seeing the response. I ran into the same problem with a private Go project I was working on a few months back, though I believe I was working with MergeE(), or maybe it was AddE(). It might have been in a traversal where I was trying to combine MergeV() and MergeE() calls. I can't recall my workaround and can't seem to find the relevant code. More examples in Go are needed, especially for the mutation steps.

-Josh 

Yang Xia

unread,
May 30, 2023, 4:29:29 PM5/30/23
to gremli...@googlegroups.com
I believe the correct type of map to use for the step is map[interface{}]interface{}, instead of map[string]interface{}, in order to properly serialize the T.label enum to the server.

So the query would look like: 
g.MergeV(map[interface{}]interface{}{"some condition": 1}).Option(gremlingo.Merge.OnCreate, map[interface{}]interface{}{gremlingo.T.Label: "label1"}).Iterate()

as provided by the answer to this question in the TinkerPop Discord: https://discord.com/channels/838910279550238720/1112616814401302558. (Feel free to join the discussions on the TinkerPop Discord server!)

Cheers,

Yang

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/1ce7c730-f811-4275-87b9-aeacc09e19cen%40googlegroups.com.

Jim Idle

unread,
May 30, 2023, 8:10:14 PM5/30/23
to gremli...@googlegroups.com
Yes. That was my sis odd question as it seems that discord has more or less replaced this group. 

You can also see my workaround there, which is to list the OnCreate after the OnMatch and call a function to add the label to the property set for OnCreate. The other way would be to dup the props and add the label, or list them inline. In,one is ok for one or two properties. 

Reply all
Reply to author
Forward
0 new messages