Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AWS Dynamodb GSI – can we create partition key if our key is present in array of object in OG table

I have a table called "Purchase_List" that includes a property named "bills". This "bills" property is an array of objects. Your objective is to query the elements inside the "bills" property, so you came up with an idea to create a Global Secondary Index (GSI). In this GSI, you plan to use the "id" present inside the "bills" array as the partition key. However, you’re unsure whether this is a valid approach. Could you please clarify if this is possible?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It’s not possible to create a Global Secondary Index on a nested value, be that in a list type or map type.

Tables and index partition keys must be top level attributes with valid data types: Strong, Number, Binary.

From your description, for every object in the bill type, I would create a new item, this is known as vertically sharding your item. That would allow you to have ID as the top level attributes allowing you to index as needed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading