In Gremlin, after a Both() step, filter based on direction we just traversed

1241 views azure-cosmosdb

I'd like to be able to do separate filters based on the direction of the traversal after a Both() step. Here's a simplified query:

g.V("1").Both().Or(<direction was IN>, __.Has("tag", "some Value"))

I also considered doing separate In() and Out() steps, but I don't see a way to have the traverser branch in both directions.

answered question

1 Answer


I think it might be more clear to traverse In() and Out() separately. You can branch the traverser with union() and thus do:

g.V("1").Union(In().has("tag","some Value"),
               Out().has("tag","some Other Value"))

posted this

Have an answer?


Please login first before posting an answer.