Python 在Dynamodb数据库中搜索

Python 在Dynamodb数据库中搜索,python,amazon-web-services,aws-lambda,amazon-dynamodb,aws-api-gateway,Python,Amazon Web Services,Aws Lambda,Amazon Dynamodb,Aws Api Gateway,我使用的是Lambda、API网关和Dynamodb,使用的是python 3.6 我有一个dynamodb表格用于订单id: orderId主键|字符串 orderStatus字符串 订单代码字符串 日期字符串 OrderId是唯一的。 每当我尝试按日期查询时,都会出现以下错误: { "errorMessage": "An error occurred (ValidationException) when calling the GetItem operation: The provide

我使用的是Lambda、API网关和Dynamodb,使用的是python 3.6 我有一个dynamodb表格用于订单id:

orderId主键|字符串 orderStatus字符串 订单代码字符串 日期字符串 OrderId是唯一的。 每当我尝试按日期查询时,都会出现以下错误:

{
  "errorMessage": "An error occurred (ValidationException) when calling the GetItem operation: The provided key element does not match the schema",
  "errorType": "ClientError",
  "stackTrace": [
    [
      "/var/task/lambda_function.py",
      8,
      "lambda_handler",
      "\"date\":day"
    ]
我的代码:

进口boto3 dynamodb=boto3.资源“dynamodb” 表=发电机B.表“车间” def lambda_handlerevent,上下文: 天=事件[‘天’] resp=table.get\u itemKey={ 日期:日 } 返回响应['Item'] 我想编写一个以一个日期作为输入并返回当天所有订单的查询:

这是我的意见:

{
  "day": "191215"
}

在DynamoDB中,您试图做的是不可能的。无论是查询还是尝试查询,都必须提供主键

当然,你可以,但你可能知道这是一个非常昂贵的操作

您始终可以创建一个日期作为主键的索引,并改为查询索引