I have created a table TEST which has 4 columns:
column1 : Range key
column2: Sort key
column3: GSI
column4: normal attribute
Now I want to update value of column4 based on GSI value. I tried with the following code but it works only when I pass both the range and sort key. In my usecase at the time of update I would have only the value of GSI not the range/sort key.
Map<String, AttributeValue> key = new HashMap<>();
key.put(“column1”, new AttributeValue().withS(column1Value));
key.put(“column2”, new AttributeValue().withS(column2Value));
Map<String, AttributeValue> attributeValues = new HashMap<>();
attributeValues.put(“column4”, new AttributeValue().withS(column4Value));
attributeValues.put(“column3”, new AttributeValue().withS(column3Value));
UpdateItemRequest updateItemRequest = new UpdateItemRequest()
.withTableName(emailsTableName)
.withKey(key)
.withUpdateExpression(“set column4 = :column4”)
.withConditionExpression(“column3 = :column3”)
.withExpressionAttributeValues(attributeValues);
UpdateItemResult updateItemResult = dynamoDBClient.updateItem(updateItemRequest);
Is this possible to update column of Dynamo DB based on GSI only?