Search code examples
gremlinamazon-neptunetinkerpop3

Losing starting vertex in search result


I have graph, where i am trying to find certain vertex's from given vertex, but in the search result I am not getting the starting vertex. Below is the query I am trying which loose the starting vertex.

g.V().has("orgId", 102)
.repeat(bothE().otherV().simplePath())
.until(hasLabel("ORG"));

If I use emit() after has() function it prints all the the vertex's coming in the path, which is not required. I only need the ending vertex based on until condition. We can try and execute here https://gremlify.com/w6o0d8htpt/8

Where as if we go for path(), it gives the starting vertex in the result, but we do not need path here. I am only looking for ending vertex.


Solution

  • The union() step should do fine here:

    g.V().has("orgId", 102).union(
        __.identity(),
        __.repeat(bothE().otherV().simplePath())
           .until(hasLabel("ORG"))
        );