3
votes

Hi every body i am working on dynamodb and very new to this technology i studied it with detail and i have been stuck in a problem since last week and could not found any help. i want to use the partition key of Global secondary index to update and delete item rather than using partition key of Base table. i could not get any way to update and delete items in dynamodb using partition key Global secondary index.

 DynamoDB dyn = new DynamoDB(dynamoDB);
Table table = dyn.getTable(tableName);
com.amazonaws.services.dynamodbv2.document.Index index = 
table.getIndex(indexName);
index.updateItemRequest(); // not supported
2

2 Answers

2
votes

You cannot delete an item using the key of the Global Secondary Index (GSI).

In order to delete an item you need the table's key (partition key + sorting key). One way to get this key is by querying the GSI.

So: GSI Key -> query on GSI -> Table Key -> Delete.

Update works the same way: GSI Keys -> query on GSI -> Table Key -> Update.

0
votes

Using GSI you cannot update/delete the records. For doing so you will have to retrieve the partition keys of the records using index.

For reference - AWS Document for GSI