gpt4 book ai didi

azure - 如何获取azure搜索的所有结果?

转载 作者:行者123 更新时间:2023-12-05 00:14:31 26 4
gpt4 key购买 nike

目前我正在创建一个应用程序,我需要调用 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

问题是,表中共有 1127 行与此特定搜索相关。但我只得到其中的前 50 个,并带有以下 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 条记录,因此您需要发出多个查询来获取分页结果。

关于azure - 如何获取azure搜索的所有结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46711376/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com