Reputation: 167
Is it possible to create a single query on multiple hash key values simultaneously using DynamoDBMapper on a GSI? For example, if I'm trying to get all relevant records in a table Table using a GSI I'd iterate through all my hash key values and make a separate query for each hash key value.
i.e. currently I'm doing
for (String s : listOfStrings) {
Attribute thing = new Attribute();
thing.setSomeField(s);
DynamoDBQueryExpression<Attribute> queryExpression =
new DynamoDBQueryExpression<Attribute>()
.withHashKeyValues(thing)
.withIndexName("example-GSI")
.withConsistentRead(false);
}
But I'd like to do everything in a batch call rather than a for loop.
I've checked the DynamoDBMapper documentation and it appears that there is none, but I was just wondering if anyone out here had any good solution for this case.
Upvotes: 6
Views: 5402
Reputation: 7669
No. DynamoDB doesn't support that. When I need to run queries on multiple hash keys, I use a loop and query them one at a time. You could also send parallel requests, if you prefer.
Upvotes: 5