DynamoDB全局辅助索引复合排序键

发布于 2025-02-13 04:13:58 字数 712 浏览 0 评论 0原文

我是DynamoDB的新手,并尝试为加法访问模式创建全局辅助索引。

如何使用复合排序键创建DynamoDB GSI?

例如:我的主要表存储订单,其中包含这些字段user_ididtypeproduct_name,<代码> total_value ,create_at

在我的主表上,分区密钥是user_id create> create_at ,所以我可以获取UI的用户订单历史记录。 我的应用程序还需要通过name获得所有订单,由type过滤,由total_valuecreate> 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱我好吗 2025-02-20 04:13:58

没有值的自动串联。您需要为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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文