Cosmos DB的查询结果如何通过指定每页的项目数来执行分页?
How to execute pagenation by specifying the number of items per page for the query result of Cosmos DB?
我打算开发一个应用程序,使用 Azure Functions(Http 触发器)对 Cosmos DB 执行查询,returns查询结果作为响应,并在 WEB 上显示响应-UI.
我正在尝试对查询结果进行分页,因为长查询结果可能会超过 Azure LB 超时默认值(230 秒)。
在使用continuation token进行分页的情况下,分页会在查询结果达到maxItemCount之前发生,例如当响应大小超过上限时。
https://docs.microsoft.com/en-us/azure/cosmos-db/concepts-limits#per-request-limits
在 RDB SQL 中指定 OFFSET 和 LIMMIT 的方法已被 Micosoft 弃用,据报道它无法正常工作。
Cosmos db OFFSET LIMIT clause is not working
Cosmos DB的查询结果如何通过指定每页的项目数来执行分页?
您可以试试这个代码:
CosmosQueryRequestOptions queryOptions = new CosmosQueryRequestOptions();
Iterable<FeedResponse<Family>> feedResponseIterator =
container.queryItems(query, queryOptions, Family.class).iterableByPage(continuationToken,pageSize);
更多细节,可以参考这篇link。
我打算开发一个应用程序,使用 Azure Functions(Http 触发器)对 Cosmos DB 执行查询,returns查询结果作为响应,并在 WEB 上显示响应-UI.
我正在尝试对查询结果进行分页,因为长查询结果可能会超过 Azure LB 超时默认值(230 秒)。
在使用continuation token进行分页的情况下,分页会在查询结果达到maxItemCount之前发生,例如当响应大小超过上限时。
https://docs.microsoft.com/en-us/azure/cosmos-db/concepts-limits#per-request-limits
在 RDB SQL 中指定 OFFSET 和 LIMMIT 的方法已被 Micosoft 弃用,据报道它无法正常工作。
Cosmos db OFFSET LIMIT clause is not working
Cosmos DB的查询结果如何通过指定每页的项目数来执行分页?
您可以试试这个代码:
CosmosQueryRequestOptions queryOptions = new CosmosQueryRequestOptions();
Iterable<FeedResponse<Family>> feedResponseIterator =
container.queryItems(query, queryOptions, Family.class).iterableByPage(continuationToken,pageSize);
更多细节,可以参考这篇link。