Cursor selection (scroll search)
Select cursor value from Optimizely Graph.
Cursor is useful when retrieving large amounts of documents. The backend system will preserve the results and response with the cursor value.
You get the cursor value from the query in the Optimizely Graph Client using theGetCursor method. Then, retrieve the subset of preserved documents using theSetCursor method.
The following is an example for scanning all documents in typeMyDocument:
var cursorQuery = queryBuilder.ForType<MyDocument>() .GetCursor() .ToQuery() .BuildQueries();//get cursor valuevar cursor = cursorQuery.GetResultAsync<MyDocument>().Result.Content.First().Cursor;//build the next sub-set queryvar subsetQuery = queryBuilder.ForType<MyDocument>() .SetCursor(cursor) .Field(x=> x.Name) .ToQuery() .BuildQueries();var nextSubset = await subsetQuery.GetResultAsync<MyDocument>().Content.Hits;while(nextSubset != null){ //continue to get nextSubset until the result is null.}Updated 22 days ago
