Limits and Offsets
By default, Collection#query
will return the “first” 50 records that match the query constraints.
If you wish to modify these, you can do that with the #limit
and #offset
arguments to the #query
call.
Both these methods take a single integer argument, like this:
collection.query(limit: 10, offset: 30) do |r|
r.allText.match("Awesome!")
r.order_by("uid", :ASC)
end
The inclusion of the #order_by
isn’t strictly required, but by default, query results do not have a stable sorting order.
This means that which 10 records you get, and which 30 are skipped, can change every time you run the query.
You should always include at least one sort specification, especially if you are using limit/offset for pagination.