0

I have a GSI setup on my personId field:

@DynamoDBIndexHashKey(attributeName = "personId", globalSecondaryIndexName = "personIndex")

private UUID personId;

Now the use case is where I will get a request containing List<UUID> personsIds and I need to query the DDB and get the results.

One option that I know is that I will have to call dynamoDB one by one to get the results.

Is there a way where this can be done in a single call (a batch request may be) ? Though I am not sure if that is possible using GSI.

Would appreciate any help in this.

Thanks.

newLearner
  • 637
  • 1
  • 12
  • 20
  • BatchGetItem only works with primary keys. You likely need to scan with an IN filter expression or issue N queries. – jarmod Mar 22 '22 at 14:25
  • The `TableKeysAndAttributes` class accepts both Hash and Range keys with for Primary Indices, but the source has no mention of GSIs. See [Reference](https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/document/TableKeysAndAttributes.html) and [examples](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/JavaDocumentAPIItemCRUD.html#JavaDocumentAPIGetItem) – Hephaestus Mar 16 '23 at 01:46

0 Answers0