I have of the non-primary key column in DynamoDb which is of List type as this:
logs=[{
m1:{"key1":"pair1",
"key2":"pair2",
"timestamp":2189321.212
},
m2:{"key1":"pair1",
"key2":"pair2",
"timestamp":2112321.212
},
...
}]
So problem statement is I want to get a list of items, which are 30 days old. I am not able to query this one.
It is not possible to do that directly using DynamoDB functions.
You could load and serialise each table log item into an object in your code, then sort and filter the objects. If you had a lot of log files this could use up a lot of memory.
If you are in control of how the log data is stored, you may want to remodel your tables, so that the logs are stored as table items. You could make log id your partition key and the timestamp a range key, which would make time based queries very fast.
If you went down that route, be aware that you would need to make your timestamp a number in DynamoDB in order to use it as a range key.
Let me know if below is useful.
I had my data inserted like this through CLI:

This is how it would look once entered:

And through Java code simply mapped it like this. This works.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With