GlobalSecondary在DynamoDB中的索引

huangapple 未分类评论42阅读模式
英文:

GlobalSecondary index in DynamoDB

问题

我需要在 DynamoDB 中创建一个全局二级索引。我的主表结构如下 -

    {
      "primaryId" : "1234", //HashKey
       "dummy1" : "kkd",
       "dummy2" : "ddd",
       "secondObj": [{
                     "secondObjId" : "1234",
                     "name" : "1234",
                    },
                    {
                     "secondObjId" : "12345",
                     "name" : "12345",
                    }]
     
    }

现在我需要基于 "secondObjId" 创建一个全局二级索引。是否可以创建呢?

我已经在 AWS 控制台上创建了它,但显示的项目数为 0,如果我使用 "dumy1" 创建 GlobalSecondaryIndex,则显示的项目数是正确的。

所以我的问题是,是否可以根据 DynamoDBDocument 中的属性创建全局二级索引?
英文:

I have to create a Global Secondary Index in Dynamo Db. My Primary table structure is below -

{
  "primaryId" : "1234" //HashKey
   "dummy1" : "kkd",
   "dummy2" : "ddd",
   "secondObj": [{
                 "secondObjId" : "1234",
                 "name" : "1234",
                },
                {
                 "secondObjId" : "12345",
                 "name" : "12345",
                }]
 
}

Now i have to create GlobalSecondary Index based on "secondObjId" as a hashkey. is it possible to create?

I have created it using AWS console but its showing item count 0 and if i am creating GlobalSecondaryIndex using "dumy1" then its showing proper item count.

So my query is that is it possible to create a GlobalSecondayIndex based on a attribute from DynamoDBDocument?

答案1

得分: 0

索引只能建立在顶级 JSON 属性上。此外,DynamoDB 中的范围键必须是标量值(String、Number、Binary 或 Boolean 之一)。

英文:

Indexes can be built only on top-level JSON attributes. In addition, range keys must be scalar values in DynamoDB (one of String, Number, Binary, or Boolean).

huangapple
  • 本文由 发表于 2020年4月8日 20:56:42
  • 转载请务必保留本文链接:https://java.coder-hub.com/61101219.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定