DynamoDB:过滤器表达式只能包含非主键属性 [英] DynamoDB: Filter Expression can only contain non-primary key attributes
本文介绍了DynamoDB:过滤器表达式只能包含非主键属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过DynamoDB控制台查询GSI,如屏幕截图所示。
I can query a GSI via DynamoDB console as can be seen in the screenshot.
当我在Boto3上运行相同的查询时终端,其代码如下:
When I run the same query with Boto3 on terminal with the following code:
table.query(
IndexName='date-timestamp-index',
KeyConditionExpression=Key('date').eq('20161231'),
FilterExpression=Attr('timestamp').between(1483130000, 1483133600) & Attr('tags').exists()
)
我收到 ValidationException
例外:
Filter Expression can only contain non-primary key attributes: Primary key attribute: timestamp
我在这里做错了什么?
What am I doing wrong here? Thanks.
推荐答案
您的时间戳
字段是表的排序键,因此不能在FilterExpression中使用。它必须是KeyConditionExpression的一部分。
Your timestamp
field is the sort key of the table, so it cannot be used in FilterExpression. It must be part of the KeyConditionExpression.
这篇关于DynamoDB:过滤器表达式只能包含非主键属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文