0

Sample Data

A knows B
A knows C
A knows D
B knows E
C knows F

Desired Output

B
C
D
E
F

I tried the following query, but it's not working,

g.V('A').
out('knows').
as('x').
out('knows').
as('x').
project('Employee').
by(select('x'))

1 Answers1

1

If you just want to get all the vertices in the path you can do:

g.V('A').repeat(out("knows")).emit().label()

example: https://gremlify.com/c533ij58a98z8

noam621
  • 2,766
  • 1
  • 16
  • 26
  • Is it possible to add a projection after? – Kajal Patel Jun 08 '20 at 10:33
  • @KajalPatel after the `g.V('A').repeat(out("knows")).emit()` you can do whatever you need. you have all the vertices, I added the `label` step just because of your desire output – noam621 Jun 08 '20 at 10:35
  • I did try that, but I am getting this error, **The provided traversal or property name of path() does not map to a value.** – Kajal Patel Jun 08 '20 at 10:47
  • what did you try? If you using `project` make sure all your `by` steps are mapping to a value. if you need help extend the gremlify example and send it here. – noam621 Jun 08 '20 at 10:48
  • I got that. But can you help with something, suppose want to project a constant with B,C,D and a different constant with E,F. Is this possible? Basically, differentiate the output based on what level it was found. – Kajal Patel Jun 08 '20 at 10:59
  • @KajalPatel You can add `sack` for depth: https://gremlify.com/c777wa0c9lsvx – noam621 Jun 08 '20 at 12:17
  • I think that's not supported in Cosmos DB Gremlin API, is there an alternative? – Kajal Patel Jun 09 '20 at 11:07