【发布时间】:2017-01-28 04:48:26
【问题描述】:
我有 2 个属性 id(字符串,主键),值(字符串)的表。 当我尝试遵循 KeyConditionExpression 时,它会抛出 Query key condition not supported。
KeyConditionExpression: "begins_with(ID, :tagIDValue)"
or
KeyConditionExpression: "contains(ID, :tagIDValue)"
从this 链接我了解到我们只能在主键上使用 EQ 操作。我怎样才能做到这一点
解决办法:=========================================== ============
我需要使用 begin_with 或 contains 来过滤所以我采用了以下方法。
表格属性:PK(partion_key, string), ID(sort key, string), value(string)。
现在我的主键是基于 PK,ID 框架的
PK 将具有所有行的恒定值。所以 KeyConditionExpression 会像。
KeyConditionExpression: "PL = :pk and begins_with(ID, :tagIDValue)"
注意:但仍然包含不能使用 KeyConditionExpression。我认为它已从 KeyConditionExpression 中删除
【问题讨论】:
-
您自己的“解决方案”向我展示了“PL = :pk and begin_with(ID, :tagIDValue)”的正确语法。谢谢你。这在 AWS 文档中不是很清楚。
标签: amazon-web-services amazon-dynamodb