不支持查询键条件,python
Query key condition not supported, python
response = tblEth_orders.query(
IndexName = 'date-index',
KeyConditionExpression= '#temp >= :myDate',
ExpressionAttributeValues= {
':myDate': week_ago_t
},
ExpressionAttributeNames= {
"#temp": "date"
}
)
response = response['Items']
print(response)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Query operation: Query key condition not supported
请告诉我另一种解决此错误的方法。
这是因为关键条件不正确。
如果您的索引 ('date-index') 只有一个分区键,那么您只能在键条件表达式中使用“=”运算符。您只能获取。
如果您的索引 ('date-index') 有一个分区键和一个排序键,那么您可以在分区键和几乎任何标准的键条件表达式中使用“=”运算符排序键的比较运算符。 “<”、“>”等运算符。
有关可用运算符的文档,请参阅此处:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html
response = tblEth_orders.query(
IndexName = 'date-index',
KeyConditionExpression= '#temp >= :myDate',
ExpressionAttributeValues= {
':myDate': week_ago_t
},
ExpressionAttributeNames= {
"#temp": "date"
}
)
response = response['Items']
print(response)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Query operation: Query key condition not supported
请告诉我另一种解决此错误的方法。
这是因为关键条件不正确。
如果您的索引 ('date-index') 只有一个分区键,那么您只能在键条件表达式中使用“=”运算符。您只能获取。
如果您的索引 ('date-index') 有一个分区键和一个排序键,那么您可以在分区键和几乎任何标准的键条件表达式中使用“=”运算符排序键的比较运算符。 “<”、“>”等运算符。
有关可用运算符的文档,请参阅此处: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html