I need to get ALL the data (a large amount) from the past two months from a table in DynamoDB. As I don't need in this case the partition key in the condition, and Scan doesn't retrieve all the data, I've read that it's possible (if I'm not mistaken) to make a query with a secondary index, so I did but I keep getting this error:
{"message":"Query key condition not supported"}
May be there's something I'm missing? Do you recommend another approach? Thanks!
This is my code:
const dateFilter = {
':from_time': twoMonthsAgo,
':to_time': todayFormatted,
};
const paramsQuery: DocumentClient.QueryInput = {
TableName: JSON.parse(process.env.dynamoTables).myTable,
IndexName: 'timeStamp-index',
ExpressionAttributeNames: { '#time': 'timeStamp' },
KeyConditionExpression: '#time BETWEEN :from_time and :to_time',
ExpressionAttributeValues: dateFilter,
};
this.dynamoClient.query(paramsQuery, (error, data) => {
if (error) {
callback(error, null);
} else {
callback(null, this.operations);
}
});