Reputation: 4084
I know that by default Azure search will return 50 rows and maximum, it can return 1000 in one request. Then I need to use the continueToken to get the rest.
However, when I use SearchServiceClient and SearchParameters to do a query with the SDK, seems I can't pass a parameter to say how many rows I want to return in one request. Did I miss something? There is my simple code, just to return everything.
(what I want is that for certain scenario, return max 50 rows per request, but in other scenario, return 1000 rows per request and loop to get the rest).
var _searchClient = new SearchServiceClient(searchServiceName, new SearchCredentials(apiKey));
var _indexClient = _searchClient.Indexes.GetClient("unit");
SearchParameters sp = new SearchParameters() { SearchMode = SearchMode.All};
var result= _indexClient.Documents.Search(null , sp);
Upvotes: 0
Views: 238
Reputation: 620
Azure Cognitive Search provides a model class SearchParameters
in Microsoft.Azure.Search.Models
namespace for the .NET SDK. You can set the Top
and Skip
properties to control the number of returned docs.
Refer to docs for SearchParameters for more properties. The following article gives examples of using this parameters with search - How to use Azure Cognitive Search from a .NET Application
Upvotes: 1
Reputation: 20097
In Azure Cognitive Search, you use the $count
, $top
, and $skip
parameters to return the number of search results . The following example shows a sample request for total hits on an index called "online-catalog", returned as @odata.count
:
GET /indexes/online-catalog/docs?search=*&$top=15&$skip=0&$count=true
For more details, you could refer to this article.
Upvotes: 0