Gremlin console with remotes

54 views
Skip to first unread message

Cristian Tarsoaga

unread,
Jul 15, 2016, 8:33:51 AM7/15/16
to Gremlin-users
Hi,

I am trying to use the gremlin console with some basic queries.

Using a local graph, I have no problem whatsoever running these:

g=TinkerGraph.open()
x
=g.addVertex('name','one')
y
=g.addVertex('name','two')
x
.property('name',1)
x
.property('name')
x
.addEdge('needs',y)


Instead, when using a remote graph (I use the titan backend), the same queries don't work anymore

:rem connect tinkerpop.server conf/remote-objects.yaml
:> graph.addVertex('name','one') //cannot use x, returns vertex id, e.g. 1111
:> graph.addVertex('name','two') //cannot use y, returns vertex id, e.g. 2222
:> graph.traversal().V(1111).property('name',1)
:> graph.traversal().V(1111).property('name') //error A
:> graph.traversal().V(1111).addEdge('needs', 2222) //error B




1st error

A: No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.property() is applicable for argument types: (java.lang.String) values: [name]

so I tried

:> graph.traversal().V(1111).properties('name') //Request timed out while processing - increase the timeout with the :remote command

which fails, but oddly enough dropping the same thing works

:> graph.traversal().V(1111).properties('name').drop() //works, property is removed

also, values() seems to work

:> graph.traversal().V(1111).values('name') //ok

Q1: what happens with property() getter?





2nd error

B: No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.addEdge() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [test, 2222]


I also tried
:> graph.traversal().V(1111).addEdge('needs', graph.traversal().V(2222))

which is also incorrect, I get this error

No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.addEdge() is applicable for argument types: (java.lang.String, org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) values: [cc, [GraphStep([2222],vertex)]]

Q2: how do I add an edge?


Thanks in advance,
regards
Chris

Stephen Mallette

unread,
Jul 15, 2016, 8:58:33 AM7/15/16
to Gremlin-users
The short answer is that there is no session for :remote in the version of Titan you are using. So, trying to assign the variable "x" then referencing i on the next request won't work. You would have to submit a multi-line script i guess:


As of TinkerPop 3.1.2, the console does support sessions:


As for other errors you had, you are running afoul of "iterating your traversal" - you should read the Gremlin Console tutorial before going any further with Gremlin:




--
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/a6d17588-162c-47ed-9b01-ba42852f61f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cristian Tarsoaga

unread,
Jul 18, 2016, 8:15:12 PM7/18/16
to Gremlin-users
thanks a lot

Q2 solved with this query

:> graph.traversal().V(1111).next().addEdge('needs', graph.traversal().V(2222).next())

Daniel Kuppitz

unread,
Jul 19, 2016, 4:39:45 AM7/19/16
to gremli...@googlegroups.com
:> graph.traversal().V(1111).next().addEdge('needs', graph.traversal().V(2222).next())

That's ugly, better do this (requires TP 3.2+):

:> g.V(1111).as("a").V(2222).addE("needs").to("a")

Cheers,
Daniel


Reply all
Reply to author
Forward
0 new messages