I have a table consisting of some records, and a created_on
column which is a date (stored as milliseconds since epoch, with an N
type).
I'd like to be able to query all records which were created before today's date, but I'm having a lot of issues with it.
I tried adding a global secondary index on created_on
, and I tried a query with the expression created_on <= :v1
. However this gave the error com.amazonaws.AmazonServiceException: Query key condition not supported
Some googling led me to believe that I'd need to use scan rather than query, with a filter expression. So I'm now attempting:
Map<String, AttributeValue> args = //build map with key ':v1' and value of date's timestamp here
DynamoDBScanExpression q = new DynamoDBScanExpression()
.withIndexName('created_on-index')
.withFilterExpression("created_on > :v1")
.withExpressionAttributeValues(args);
return mapper.scan(type, q);
This runs without an error, but returns 0 records. I've verified that the milliseconds it returns are of today's date, and there are 3 records in the table for which the condition should match.
Any ideas?