Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB GSI using boolean like a hash key


It's just a doubt that i cant find on the internet.
I have a table like this:

|  id | infos | ignored |
|  1  | abc  | true       |
|  2  | def   | false      |
|  3  | ghi   | false      |

I see i cant create a DynamoDB GSI on booleans columns. It's right?
I want to create a GSI on this ignored column.

like image 749
Rafael de Carvalho Avatar asked Feb 15 '26 20:02

Rafael de Carvalho


1 Answers

The DynamoDB console only allows GSIs using types of string, binary, or number.

enter image description here

So you could use strings ("t" or "f"), numbers (1 or 0) or binary (also 1 or 0) to represent a boolean value if you'd like.

It sounds like you're trying to build a sparse index (e.g. only certain items are in the index). Keep in mind that you can do this by the mere existence of the attribute that makes up the GSI.

For example, you could include the ignored attribute on items you want to project into the index and remove the ignored attribute from items you do not want in the index.

like image 93
Seth Geoghegan Avatar answered Feb 18 '26 11:02

Seth Geoghegan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!