DynamoDB全局辅助索引复合排序键
我是DynamoDB的新手,并尝试为加法访问模式创建全局辅助索引。
如何使用复合排序键创建DynamoDB GSI?
例如:我的主要表存储订单,其中包含这些字段user_id
,id
,type
,product_name
,<代码> total_value ,create_at
在我的主表上,分区密钥是user_id
create> create_at ,所以我可以获取UI的用户订单历史记录。 我的应用程序还需要通过name
获得所有订单,由type
过滤,由total_value
和create> created_at
排序。 因此,我正在考虑使用以下
- 方式创建一个GSI:
product_name
- sort key:
type#tote#tote_value#create_at
,
但是当创建新的GSI时,我遇到了此错误:
属性定义中未指定的全局辅助索引范围密钥未知。
那么,我该怎么做才能创建该GSI呢?
I'm new to dynamodb and trying to create a global secondary index for addition access patterns.
How can I create dynamoDB GSI with composite sort key?
For example: my primary table stored orders, which has these fields User_ID
,ID
, Type
, Product_name
, Total_Value
, Created_at
On my primary table, the partition key is User_ID
and sort key is Created_at
, so I can get user's order history for the UI.
My application also needs to get all orders by name
, filtered by type
, sorted by total_value
and Created_at
so I'm thinking of create a GSI with:
- Parition key:
Product_name
- Sort key:
Type#Total_value#Created_at
But when creating a new GSI I encountered this error:
Global Secondary Index range key not specified in Attribute Definitions.Type unknown.
So what should I do to create that GSI?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有值的自动串联。您需要为GSI排序键创建一个属性(使用任何法律属性名称),构造引用它的GSI,然后(通过您的代码)将其置于您想要的串联值。
There is no automatic concatenation of values. You need to create an attribute for the GSI sort key (using any legal attribute name), construct a GSI referencing it, and put into it (via your code) the concatenated value you want there.