4
votes

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.

1

1 Answers

5
votes

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.