简体   繁体   中英

how to “join” two vertices on Gremlin?

I meet some trouble with Gremlin console; here is my schema.

格林姆林

Knowing:

  • ID 1 (vertex)
  • ID 3 (vertex)
  • Label: "created" (edge)

I would like to get ID 9 (edge)

v = gv(1)

v.outE("created").id

only works if there is only one "created" edge

You can do:

g.e(9)

or, filtering from v[1]:

g.v(1).outE('created')[[id:9]]

or, if you mean getting the created edges between vertex 1 and 3:

g.v(1).outE('created').as('x').inV[[id:3]].back('x').id
g.v(1).outE('created').inV[[id:3]].back(2).id

Hope that helps, Marko.

http://markorodriguez.com

Thanks Marko, it works fine (but I have to use id:'3' instead of id:3).

And by the way, is this code:

g.v(1).outE('created').as('x').inV[[id:'3']].back('x').id

more efficient than this one:

g.v(1).outE.as('x').inV[[id:'3']].back('x').id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM