如何从天蓝色搜索中获取所有结果?

How to get all results from azure search?

目前我正在创建一个应用程序,我需要在其中调用 API 进行 azure 搜索。调用此 API :

https://<searchServiceName>.search.windows.net/indexes/<index-name>/docs/search?api-version=2016-09-01

还为搜索查询提供所有必需的参数:

(test||test||test||test||test||test||test)+ Contacts+Campaigns+Companies+Targets+Complanits+Claims+Activities+Opportunities+Completed Activities

问题是,table 中共有 1127 行与此特定搜索相关。但是我只有前五十个带有以下 JSON 对象输出。

"@search.nextPageParameters": {
        "search": "(test||test||test||test||test||test||test)+ Contacts+Campaigns+Companies+Targets+Complanits+Claims+Activities+Opportunities+Completed Activities",
        "skip": 50}

我应该对查询进行哪些更改才能获得全部 1127 个或更多结果?

这是预期的行为。来自 documentation(请参阅有关 $top 查询参数的文档):

$top=# (optional)

The number of search results to retrieve. This defaults to 50. When calling via POST, this parameter is named top instead of $top. If you specify a value greater than 1000 and there are more than 1000 results, only the first 1000 results will be returned, along with a link to the next page of results (see @odata.nextLink in the example below).

Azure Search uses server-side paging to prevent queries from retrieving too many documents at once. The default page size is 50, while the maximum page size is 1000. This means that by default Search Documents returns at most 50 results if you don't specify $top. If there are more than 50 results, the response includes information to retrieve the next page of at most 50 results (see @odata.nextLink and @search.nextPageParameters in the Examples below. Similarly, if you specify a value greater than 1000 for $top and there are more than 1000 results, only the first 1000 results are returned, along with information to retrieve the next page of at most 1000 results.

基于此,您需要做一些事情:

  1. $top 参数指定一个值。因为您没有指定任何值,所以返回默认记录数(即 50)。
  2. 由于单个请求最多只能获取 1000 条记录,而您提到索引包含超过 1000 条记录,因此您需要发出多个查询才能获取分页结果。