I'm trying to get data from a dynamoDB table sorted but also I want pagination because there are many many rows. This is my query params, control_id is GSI with timestamp as sortkey and id is primary key. I think what I need is to use both indexes in same query because right now this is what I get ValidationException: The provided starting key is invalid and if I remove ExclusiveStartKey it works.
params = {
TableName: tableName,
IndexName: 'control_id',
KeyConditionExpression: 'control_id = :ci',
ExpressionAttributeValues: {
':ci': 1
},
ScanIndexForward: false,
Limit: 250,
ExclusiveStartKey: {
'id': lastKey
}
}