0

In Gremlin, we can paginate like this:

gremlin> g.V().hasLabel('person').fold().as('persons','count').
               select('persons','count').
                 by(range(local, 0, 2)).
                 by(count(local))
==>[persons:[v[1],v[2]],count:4]

I'm trying to do the same thing in Java, but have no idea what local is in this case. My current query looks like this:

.fold()
.as("persons", "count")
.select("persons", "count")
.by(__.range(0, 2))
.by(__.count())

However, it always returns all results with a count of 1. How would the pagination be correctly performed in Java?

Double M
  • 1,449
  • 1
  • 12
  • 29

1 Answers1

2

The details for pagination are described best here but your question seems like it's more about use of local. local is an value from the enum Scope and a common import for all languages Gremlin is implemented in.

import static org.apache.tinkerpop.gremlin.process.traversal.Scope.local;

You can always find out more about the arguments to Gremlin steps by looking at the javadoc.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Thanks, that helped a lot. It works correctly now after adding it as parameter to `.range(Scope.local, 0, 2)` and `.count(Scope.local)`. – Double M Apr 27 '20 at 14:19