Cursor
How to get large amounts of documents using batch retrieval. The backend system preserves the state of the result set.
By default, cursor is not enabled. To enable it, select cursor to the GQL query to get the cursor in combination with a query in where
using an empty string ""
as value, such as cursor: ""
.
- The response has a cursor value and then gets the next batches using that cursor value in the GQL query.
- The results for the first query are preserved in the current state (stateful) for 10 minutes per request, and after that time, the cursor expires and is no longer valid.
- Continue until there are no more results. The number of results per batch depends on the number set by
limit
. For the first query with the cursor enabled, the skip is ignored. You can implement this by ignoring the first batches of results. - You should sort by
DOC
for the fastest retrieval. - At least one content item field must be projected, or you will get an error. Only
total
is insufficient because it is not a field of an item initems
.
Example request, where you get the batches per one document:
{
StandardPage(
cursor: "FGluY2x1ZGVfY29udGV4dF91dWlkDXF1ZXJ5QW5kRmV0Y2gBFnh3Qmszbmh0UkxPeWVGVHBLcUtQVWcAAAAAAAAATRZJVkJ4eFZBdVM5dTI4R1UzVUFSOEpn"
limit: 1
orderBy: {_ranking: DOC}
) {
items {
Name
Url
RouteSegment
Changed
}
cursor
}
}
Updated 8 months ago