bir*_*dus 2 azure azure-cognitive-search azure-search-.net-sdk
Azure 搜索一次最多返回 1,000 个结果。对于客户端上的分页,我想要匹配的总数,以便能够在底部显示正确数量的分页按钮,并能够告诉用户有多少结果。但是,如果有超过一千个,我如何获得实际计数?我只知道至少有1,000 场比赛。
我需要能够在 SDK 中执行此操作。
如果你想在一个索引文件总数量,你可以做一件事被设置IncludeTotalResultCount到true在搜索参数。在执行查询时执行此操作后,您将在Count搜索结果的属性中的索引中看到总文档数。
这是一个示例代码:
var credentials = new SearchCredentials("account-key (query or admin key)");
var indexClient = new SearchIndexClient("account-name", "index-name", credentials);
var searchParameters = new SearchParameters()
{
QueryType = QueryType.Full,
IncludeTotalResultCount = true
};
var searchResults = await indexClient.Documents.SearchAsync("*", searchParameters);
Console.WriteLine("Total documents in index (approx) = " + searchResults.Count.GetValueOrDefault());//Prints the total number of documents in the index
Run Code Online (Sandbox Code Playgroud)
请注意:
| 归档时间: |
|
| 查看次数: |
2551 次 |
| 最近记录: |