title: DynamoDB query using secondary index, how to query with different keys
body: <p>i'm using serverless framework with dynamodb [in Local].
  trying to query with secondary indexed fields. 
  goal is to query with few keys like we do in basic find queries in Mongo: <code>{url:'&lt;Somevalue&gt;'}</code> or may be like this <code>{url:&lt;somevalue&gt;,ha:&lt;somevalue&gt;}</code></p>
  
  <p>Table config i'm using currently: </p>
  
  <p><strong>serverless.yml</strong></p>
  
  <pre><code>resources:
    Resources:
      TableName:
        Type: 'AWS::DynamoDB::Table'
        Properties:
          TableName: ${file(./serverless.js):Tables.TableName.name}
          BillingMode: PAY_PER_REQUEST
          AttributeDefinitions:
            - AttributeName: 'id'
              AttributeType: 'S'
            - AttributeName: 'url'
              AttributeType: 'S'
            - AttributeName: 'ha'
              AttributeType: 'S'
            - AttributeName: 'GSI_1_PK'
              AttributeType: 'S'
            - AttributeName: 'GSI_1_SK'
              AttributeType: 'S'
          KeySchema:
            - AttributeName: 'id'
              KeyType: 'HASH'
          GlobalSecondaryIndexes:
            - IndexName: 'GSI_1'
              KeySchema:
                - AttributeName: 'GSI_1_PK'
                  KeyType: 'HASH'
                - AttributeName: 'GSI_1_SK'
                  KeyType: 'RANGE'
              Projection:
                ProjectionType: 'ALL'
            - IndexName: 'URI_1'
              KeySchema:
                - AttributeName: 'url'
                  KeyType: 'HASH'
              Projection:
                ProjectionType: 'ALL'
            - IndexName: 'HASH_1'
              KeySchema:
                - AttributeName: 'ha'
                  KeyType: 'HASH'
              Projection:
                ProjectionType: 'ALL'
  
    Outputs:
      TableNameARN:
        Value: { 'Fn::GetAtt': [TableName, Arn] }
        Export:
          Name: ${file(./serverless.js):Exports.TableNameARN}
  </code></pre>
  
  <p>with this, currently i'm only able to search with <code>id</code> field, </p>
  
  <p><strong>Q</strong>:</p>
  
  <p>1> What are the changes needs to be made to query with different fields ? [which is secondary indexed , without using <code>id</code> in the query]</p>
  
  <p>2> How do i search with multiple attributes? [i.e : <code>{url:&lt;somevalue&gt;,ha:&lt;somevalue&gt;}</code>]</p>
  
  <p>Query i'm using :</p>
  
  <pre><code>var params = {
      TableName: '&lt;TableName&gt;',
      IndexName:'URI_1',
      Key: {
        url: 'http://something.com'
      }
  };
  docClient.get(params, function(err, data) {
      if (err) ppJson(err); // an error occurred
      else ppJson(data); // successful response
  });
  </code></pre>
  
  <p>Output of the query:</p>
  
  <pre><code>{
  message:"One of the required keys was not given a value",
  code:"ValidationException,
  ...
  }
  </code></pre>