0
votes

I am trying fetch items from DynamoDB using BatchGetItem. I'm searching in 2 tables. This is the example I am following. Is hash key and range key mandatory to fetch items? I want to fetch using attributes which are not either hash key or range key. Is this possible using BatchGetItem? Or can we fetch with indexed attributes?

Thanks in advance.

1

1 Answers

0
votes

You need to identify the primary key for the BatchGetItem operation.

The BatchGetItem operation returns the attributes of one or more items from one or more tables. You identify requested items by primary key.

However, in Query operation, you can identify either the primary key or the secondary index. You can use FilterExpression to make sure your items satisfy a filter criteria. You cannot define a filter expression based on a partition key or a sort key.

As for the Scan operation, you don't need to provide the primary key while the secondary index is optional.

See AWS API Documentation.