title: Querying DynamoDB GSI with a list of values
body: <p>I have a table of "team memberships" with primary partition key of "team_id" , a primary sort key of "email" and a GSI with "email" as partition key. </p>
  
  <p>Given a list of emails I would like to find all the memberships for all the emails in the list in the most efficient way possible.</p>
  
  <p>I know that for a single email I can do the following:</p>
  
  <pre><code> Membership membership = new Membership();
   membership.setEmail(email.toLowerCase());
  
   DynamoDBQueryExpression&lt;Membership&gt; expression = new DynamoDBQueryExpression&lt;Membership&gt;()
                  .withHashKeyValues(membership)
                  .withIndexName(EMAIL_INDEX)
                  .withConsistentRead(false);
  
   return mapper.query(Membership.class, expression);
  </code></pre>
  
  <p>which returns a list of memberships for the given email.</p>
  
  <p>(So for my list of emails, I could do the above for each email in the list, but I would like to know if it is possible to do in one step).</p>
  
  <p>I would like to be able to do something like:</p>
  
  <pre><code>List&lt;Membership&gt; memberships = allEmails.stream().map(email -&gt; {
              Membership m = new Membership();
              m.setEmail(email.toLowerCase());
              return m;
          }).collect(Collectors.toList());
  
          DynamoDBQueryExpression&lt;Membership&gt; expression = new DynamoDBQueryExpression&lt;Membership&gt;()
                  .withHashKeyValues(memberships) // &lt;--- passing a list
                  .withIndexName(EMAIL_INDEX)
                  .withConsistentRead(false);
  </code></pre>
  
  <p>which clearly doesn't work.</p>
  
  <p>What are the alternatives?</p>