AWS Dynamodb BatchGet with FilterExpression


I want to retrieve list of items from dynamodb table based on some filters. In Filters, I have my list of hash keys (records having one of that hash key should be returned) and few more filters on the record, for example a “status” field having value as “approved”. So if the item is having hash key from my list AND status field value is “approved” it should be returned.
How can I do that ?
I cannot use QUERY because according to my understanding it expects only 1 hash key value.
I cannot use BatchGet because it does not accept filter expression.


You can user BatchGet to get the items, and filter them by your own function.

Doc: Working with Query

A Query operation can retrieve a maximum of 1 MB of data. This limit applies before the filter expression is evaluated.

As you see, use filter expression cannot help you to retrieve more data, which also cannot save your read capacity(money). So I think it make no difference to filter locally or server-side.

If you want dynamo to do the heavy lifting filtering the data for you, then you can try "multi-query" instead of BatchGet.

Here is some relevant references, What’s the difference between BatchGetItem and Query in DynamoDB?

Leave a Reply