amazon-web-services - AWS Amplify 在创建 DynamoDB 表后创建全局二级索引
问题描述
我有一个包含约 70 个表的大型架构,其中许多表相互连接(194 个@connection 指令),如下所示:
type table1 @model {
id:ID!
name: String!
...
table2: table2 @connection
}
type table2 @model {
id:ID!
....
}
这工作正常。现在我的数据量在稳步增长,我需要能够查询结果并对其进行排序。
我已经阅读了几篇文章,发现一篇文章建议我创建一个 @key 指令来生成具有 2 个字段的 GSI,因此我可以说“根据我的过滤器属性过滤结果,按字段“名称”对它们进行排序并返回前 10 个条目,其余条目可通过 nextToken 参数访问”
所以我尝试添加这样的 GSI:
type table1 @model
@key(name: "byName", fields:["id","name"], queryField:"idByName"){
id:ID!
name: String!
...
table2: table2 @connection
}
跑步
amplify push --minify
我收到错误
Attempting to add a local secondary index to the table1Table table in the table1 stack. Local secondary indexes must be created when the table is created.
An error occured during the push operation: Attempting to add a local secondary index to the table1Table table in the table1 stack.
Local secondary indexes must be created when the table is created.
为什么它会创建 LSI 而不是 GSI?在创建和填充表后,有什么方法可以将 @key 指令添加到表中?来自不同表的大量数据集相互链接,因此仅设置一个新模式需要很长时间。
如果这有一些影响,计费模式是 PAY_PER_REQUEST。
任何想法如何进行?
提前致谢!
问候克里斯蒂安
解决方案
如果您使用的是新环境,请先删除文件夹 #current-cloud-backend。
然后amplify init
再次创建了该文件夹,但可惜的是,其中只有一个文件 amplify-meta.json。
推荐阅读
- rest - Docker REST API:创建图像问题:需要参数 fromSrc 的帮助:
- python - 如何检查字典中的至少一个键是否作为Python中另一个字典中的值存在?
- javascript - AngularJS如何检查多个http请求是否完成并在所有响应完成后做某事
- node.js - node-cmd 增加 maxBuffer 大小
- mysql - MySQL 列值不存在于同一张表的其他列中
- wix - Wix - 卸载时运行批处理文件
- c - 直接从 typedef 结构定义创建指针
- r - 如何提取关于我的线性回归线的信息(例如截距和梯度)
- sql - 计算特定名称的行数
- html - Css flex 等于