title: Dynamodb: Querying tables with secondary index
body: <p>I am using the gem <a href="https://github.com/aws/aws-sdk-ruby" rel="noreferrer">aws-sdk-ruby</a> to query a table which looks something like this:</p>
  
  <pre><code>hk (Hashkey)  |  guid(Rangekey)  |  Timestamp (Secondary Range index)  |  other attributes
  aaaa          |  50              |  2013-02-04T12:33:00Z               |
  aaaa          |  244             |  2013-04-22T04:54:00Z               |
  aaaa          |  342             |  2013-05-18T06:52:00Z               |
  bbbb          |  243             |  2013-06-21T13:17:00Z               |
  </code></pre>
  
  <p>What I am trying to do is get all 'aaaa' rows that were created after a certain date.
  Ex:</p>
  
  <pre><code>AWS.config(access_key_id: 'xxx', secret_access_key: 'xxx', :dynamo_db =&gt; { :api_version =&gt; '2012-08-10' })
  client = AWS::DynamoDB::Client.new
  client.query(
  {
    table_name: 'table',
    select: 'ALL_ATTRIBUTES',
    key_conditions: {
      'hk' =&gt; {
        comparison_operator: 'EQ',
        attribute_value_list: [
          {'s' =&gt; 'aaaa'}
        ]
      },
      'timestamp' =&gt; {
        comparison_operator: 'GE',
        attribute_value_list: [
          {'s' =&gt; Time.now.utc.iso8601}
        ]
      }
    }
  })
  </code></pre>
  
  <p>When i run the code above i get this:</p>
  
  <pre><code>Query condition missed key schema element guid (AWS::DynamoDB::Errors::ValidationException)
  </code></pre>
  
  <p>Running the query with hashKey and RangeKey works but when i replace the rangeKey with a secondary range index it fails telling me that the rangeKey is required.</p>
  
  <p>If i then add the range key (Which makes no sense) i get the following error instead:</p>
  
  <pre><code>Conditions can be of length 1 or 2 only (AWS::DynamoDB::Errors::ValidationException)
  </code></pre>
  
  <p>Anyone know what might be happening?</p>