[Titan] Connecting vertices without variables

42 views
Skip to first unread message

Cecil New

unread,
Aug 16, 2016, 5:03:49 PM8/16/16
to Gremlin-users
I will be using the REST API, so I will not be able to create variables and add edges the Gremlin console way since REST will be stateless (and sessionless)... right?

I have vertices created for parts and I can find them by 'name':
:> g.V().has(label,'part').has('name', 'P100')
==> v[16488]
:> g.V().has(label,'part').has('name', 'P200')
==> v[65720]

I want to create an edge, say 'has_part' between them. This doesn't work:
:> g.V().has(label,'part').has('name', 'P100').as('a')  // first part
 .has(label,'part').has('name','P200').as('b') // second part
 .addEdge('has_part',a) // connect them... fails.

The examples in the documentation show adding edges when the vertices can be traversed by other edges. This isn't true for me. I have a set of parts and now I need to connect them, knowing only their name property.

At the moment I am using the Go driver if that makes a difference.

Thanks for the help!

Robert Dale

unread,
Aug 16, 2016, 5:38:04 PM8/16/16
to gremli...@googlegroups.com
You might be on a different version, using 3.2 here:

g.V().has(label,'part').has('name', 'P100').as('a')
  .V().has(label,'part').has('name','P200').
 .addE('has_part').to('a').iterate()



--
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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/31dd6554-e0c4-45b7-93e7-21d97ea31bc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Robert Dale

Stephen Mallette

unread,
Aug 16, 2016, 7:16:00 PM8/16/16
to Gremlin-users
> I will be using the REST API, so I will not be able to create variables and add edges the Gremlin console way since REST will be stateless (and sessionless)... right?

you can still use variables. just send a multi-line script (easy with POST and some JSON). just don't expect those variables to be available on a future request. they are scoped only to the request they are submitted on.

Cecil New

unread,
Aug 23, 2016, 12:43:11 PM8/23/16
to Gremlin-users
Thanks very much for the responses. I've been out of pocket and hope to pick this up later today.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.



--
Robert Dale

--
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.

Cecil New

unread,
Aug 23, 2016, 4:02:17 PM8/23/16
to Gremlin-users
Your example uses iterate()... I found this 29 places in the docs at http://tinkerpop.apache.org/docs/current, but none of them explain this function, why it's needed, when to use it, etc.

Is there other documentation somewhere that I'm missing?


On Tuesday, August 16, 2016 at 5:38:04 PM UTC-4, Robert Dale wrote:
You might be on a different version, using 3.2 here:

g.V().has(label,'part').has('name', 'P100').as('a')
  .V().has(label,'part').has('name','P200').
 .addE('has_part').to('a').iterate()


On Tue, Aug 16, 2016 at 5:03 PM, Cecil New <ceci...@gmail.com> wrote:
I will be using the REST API, so I will not be able to create variables and add edges the Gremlin console way since REST will be stateless (and sessionless)... right?

I have vertices created for parts and I can find them by 'name':
:> g.V().has(label,'part').has('name', 'P100')
==> v[16488]
:> g.V().has(label,'part').has('name', 'P200')
==> v[65720]

I want to create an edge, say 'has_part' between them. This doesn't work:
:> g.V().has(label,'part').has('name', 'P100').as('a')  // first part
 .has(label,'part').has('name','P200').as('b') // second part
 .addEdge('has_part',a) // connect them... fails.

The examples in the documentation show adding edges when the vertices can be traversed by other edges. This isn't true for me. I have a set of parts and now I need to connect them, knowing only their name property.

At the moment I am using the Go driver if that makes a difference.

Thanks for the help!

--
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.



--
Robert Dale

Cecil New

unread,
Aug 23, 2016, 4:26:58 PM8/23/16
to Gremlin-users
You are correct - Titan 1.0.0 comes with 3.0.1-incubating. And that looks like the latest. Bummer.


On Tuesday, August 16, 2016 at 5:38:04 PM UTC-4, Robert Dale wrote:
You might be on a different version, using 3.2 here:

g.V().has(label,'part').has('name', 'P100').as('a')
  .V().has(label,'part').has('name','P200').
 .addE('has_part').to('a').iterate()


On Tue, Aug 16, 2016 at 5:03 PM, Cecil New <ceci...@gmail.com> wrote:
I will be using the REST API, so I will not be able to create variables and add edges the Gremlin console way since REST will be stateless (and sessionless)... right?

I have vertices created for parts and I can find them by 'name':
:> g.V().has(label,'part').has('name', 'P100')
==> v[16488]
:> g.V().has(label,'part').has('name', 'P200')
==> v[65720]

I want to create an edge, say 'has_part' between them. This doesn't work:
:> g.V().has(label,'part').has('name', 'P100').as('a')  // first part
 .has(label,'part').has('name','P200').as('b') // second part
 .addEdge('has_part',a) // connect them... fails.

The examples in the documentation show adding edges when the vertices can be traversed by other edges. This isn't true for me. I have a set of parts and now I need to connect them, knowing only their name property.

At the moment I am using the Go driver if that makes a difference.

Thanks for the help!

--
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.



--
Robert Dale

Robert Dale

unread,
Aug 24, 2016, 8:44:21 AM8/24/16
to Gremlin-users

The gremlin DSL is a builder. It produces a Traversal. The Traversal has to be executed, or iterated, to actually perform work. Think of iterate() as execute without results. You could just as well call toList(). There are other terminal actions with different results. See  Traversal javadoc.  The console will iterate automatically as a convenience. Scripts or GLVs embedded or remote to a server need to call a terminal action explicitly.
Reply all
Reply to author
Forward
0 new messages