HomeDev guideAPI ReferenceGraphQL
Dev guideUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Cursor selection (scroll search)

Select cursor value from Optimizely Graph.

πŸ‘

Beta

The Optimizely Graph .NET Client is in beta. Contact your Customer Success Manager for information.

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 the GetCursor method. Then, retrieve the subset of preserved documents using the SetCursor method.

The following is an example for scanning all documents in type MyDocument:

 var cursorQuery = queryBuilder
.ForType<MyDocument>()
  .GetCursor()
 .ToQuery()
 .BuildQueries();
//get cursor value
var cursor = cursorQuery.GetResultAsync<MyDocument>().Result.Content.First().Cursor;
//build the next sub-set query
var 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.
}