indexOf Vertex with given property in a sorted list

Hi all!

I've been trying to create a paginated GET REST api and sometimes I need to enforce a range on the resulting vertices starting from a vertex matching a given ID.

Let's say my gremlin query so far returns the following list of vertices, sorted based on some property comparison:

[
  V{id:Z}
  V{id:F}
  V{id:K}
  V{id:A}
  V{id:N}
  V{id:T}
  V{id:C}
]


Is there a way of asking gremlin what is the index of vertex with id K in the above list? Can all of this be done in a single query so that my final result simply returns the following, given K and a range of 3?
[
  V{id:K}
  V{id:A}
  V{id:N}
]


Some pseudocode for clarity:
g.V()
.hasLabel("profile")
.order()
.by("date", gremlin.process.order.asc);   // at this point we have the whole list
.range(indexOf(id=K), indexOf(id=K) + 3)  // this is the hiccup,
                                          // how to find indexOf(id=K) in the sorted result
.toList()


Thank you in advance
Was this page helpful?