0
votes

I have table with hash key as ID and range key as CreatedDate. I have a scenario where i need to get the list based on first name and last name columns. I created a global secondary index (hash key: lastName, range key: firstName). This index will give me anyName equal to lastName and some condition for firstName. I want to get data for the reverse scenario also ie anyName equal to firstName and some condition on lastName.

Can i do this without actually creating a new GSI with hash key as firstName and range key as lastName(reverse of the above)?

1

1 Answers

0
votes

Unfortunately, no. You must specify a specific hash key, according to the AWS API. If you need to be able to perform the opposite, you will need to create the table with a GSI that has the opposite mapping. Keep in mind that GSIs must be specified at the time of the creation of the table

You can however perform a Scan operation, though that will incur much higher read costs than a Query operation.