I'm trying to do pagination in Gremlin. I've followed the solution provided on gremlin recipes. So right now I am using the range()
step to truncate results. This works well because when users asks for x results id only queries for x of them and doesn't perform full search which is significantly faster.
However in Gremlin docs it states that:
A Traversal’s result are never ordered unless explicitly by means of order()-step. Thus, never rely on the iteration order between TinkerPop3 releases and even within a release (as traversal optimizations may alter the flow).
And order is really important for pagination (we don't want user to have same results on different pages).
Adding order()
would really slow down querying, since it will have to query all vertices that apply to the search and then truncate it with range()
.
Any ideas how this can be solved to have consistency between queries and still have smaller query time for not-full search?