Auto Paginating Search Results in Box Windows SDK V2
I'm currently writing an integration using the Box windows sdk v2 working with the BoxClient.SearchManager.SearchAsync method.
I can see that the method takes in limit and offset. What I would like to do is have the method execute the search and return all results, regardless of the count. I've noticed that some of the other methods have an autoPaginate field. Is there something similar? If not, what is the recommend approach to pulling all results?
-
There is not currently a way to pull all search results; the recommended approach is to ask for as many as you need and then page through the results until you find what you're looking for. Here's an example of one approach you might take:
var pageSize = 30; // number of results per page, maximum 200 var offset = 0; var query = "Your Search Query";
var limit = 500; // total number of search results to retrieve while (pageSize + offset <= limit) // search through the first 500 total results { var results = await client.SearchManager.SearchAsync(query, offset: offset, limit: pageSize); if (/* you found what you wanted in the results */) { break; } offset += pageSize; }
サインインしてコメントを残してください。
コメント
1件のコメント