不提供主键的 DynamoDB BatchGetItemRequest
DynamoDB BatchGetItemRequest without providing Primary Key
AWS DynamoDB table 有:
- 客户端(主键),
- folder_location(非关键属性),
- script_name(非关键属性)
我想使用客户端和 folder_location 属性使用 BatchGetItemRequest
检索记录。
但出现以下错误:
Failed to retrieve items.com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;
有没有办法只处理 BatchGetItemRequest
?
您可以改为使用 Query or Scan operation and specify a Filter Expression 来限制基于 folder_location
的结果。
要使用 BatchGetItemRequest
,您必须根据 https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html:
提供密钥
The BatchGetItem operation returns the attributes of one or more items
from one or more tables. You identify requested items by primary key.
Keys - An array of primary key attribute values that define specific
items in the table. For each primary key, you must provide all of the
key attributes. For example, with a simple primary key, you only need
to provide the partition key value. For a composite key, you must
provide both the partition key value and the sort key value.
我建议您仔细检查您提供的密钥是否与 table(名称和数据类型)中定义的密钥匹配。如果是这样,则尝试使用 FilterExpression 的其他选项之一。
AWS DynamoDB table 有:
- 客户端(主键),
- folder_location(非关键属性),
- script_name(非关键属性)
我想使用客户端和 folder_location 属性使用 BatchGetItemRequest
检索记录。
但出现以下错误:
Failed to retrieve items.com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;
有没有办法只处理 BatchGetItemRequest
?
您可以改为使用 Query or Scan operation and specify a Filter Expression 来限制基于 folder_location
的结果。
要使用 BatchGetItemRequest
,您必须根据 https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html:
The BatchGetItem operation returns the attributes of one or more items from one or more tables. You identify requested items by primary key.
Keys - An array of primary key attribute values that define specific items in the table. For each primary key, you must provide all of the key attributes. For example, with a simple primary key, you only need to provide the partition key value. For a composite key, you must provide both the partition key value and the sort key value.
我建议您仔细检查您提供的密钥是否与 table(名称和数据类型)中定义的密钥匹配。如果是这样,则尝试使用 FilterExpression 的其他选项之一。