简体   繁体   English

如何在 AWS CLI 中将 LastEvaluatedKey 用作 ExclusiveStartKey

[英]How do you use the LastEvaluatedKey as the ExclusiveStartKey in AWS CLI

I want to show all the results of a particular table that im querying through the aws cli and this is how i structured the code.我想显示我通过 aws cli 查询的特定表的所有结果,这就是我构建代码的方式。

aws dynamodb scan --table-name core_samples --debug

This gives me back a table but its not showing all my results.这给了我一张桌子,但它没有显示我所有的结果。 So i resorted to pagination and I want to know how to add the ExclusiveStartKey from the LastEvaluatedKey as my parameters so that i could enter the code over again until I've gotten all the results of the table.所以我求助于分页,我想知道如何从 LastEvaluatedKey 添加 ExclusiveStartKey 作为我的参数,这样我就可以重新输入代码,直到我得到表格的所有结果。 The following is how i thought i was supposed to do it but it gave me a couple of errors.以下是我认为我应该这样做的方式,但它给了我一些错误。

aws dynamodb scan \
    --table-name core_samples \
    --ExclusiveStartKey <providedkey> \
    --debug

or或者

aws dynamodb scan \
    --table-name core_samples \
    --starting-token <providedkey> \
    --debug

How do i do it?我该怎么做?

The docs for the AWS CLI for DynamoDB are at https://docs.aws.amazon.com/cli/latest/reference/dynamodb/scan.html DynamoDB 的 AWS CLI 文档位于https://docs.aws.amazon.com/cli/latest/reference/dynamodb/scan.html

Using the CLI you don't get a LastEvaluatedKey, you get a NextToken and pass it back with --starting-token .使用 CLI,您不会获得 LastEvaluatedKey,您会获得 NextToken 并使用--starting-token将其传回。 The model follows the generic paging system across services with the CLI rather than being DynamoDB-specific: model 遵循使用 CLI 跨服务的通用分页系统,而不是特定于 DynamoDB 的:

--starting-token (string)

A token to specify where to start paginating. This is the NextToken 
from a previously truncated response.

For usage examples, see Pagination in the AWS Command Line Interface
User Guide.

The CLI pagination docs are at https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html CLI 分页文档位于https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html

It mentions you can opt to do client-side paging as well, like using less which is pretty cool.它提到您也可以选择进行客户端分页,比如使用less这非常酷。 Or you can set the pager to empty to just have it auto-page and scan til it's done.或者您可以将寻呼机设置为空,让它自动寻呼并扫描直到完成。

The AWS CLI implements pagination by default in DynamoDB, which is unlike the other SDK's which force client side pagination. AWS CLI 在 DynamoDB 中默认实现分页,这与强制客户端分页的其他 SDK 不同。 This means you have no need to use LastEvaluatedKey or ExclusiveStartKey unless you are stopping the request early by using Limit or FilterExpression .这意味着您无需使用LastEvaluatedKeyExclusiveStartKey除非您使用LimitFilterExpression提前停止请求。

It seems here you are not limiting your requests, so I would expect all data to be returned.在这里你似乎没有限制你的请求,所以我希望所有数据都被返回。 Ensure you check your tables data using the web console and understand that it contains the items which you expect from your CLI command.确保您使用 web 控制台检查您的表数据,并了解它包含您期望从 CLI 命令获得的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM