小编ksa*_*amc的帖子

Dynamodb:使用二级索引查询表

我使用gem aws-sdk-ruby查询一个看起来像这样的表:

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               |
Run Code Online (Sandbox Code Playgroud)

我想要做的是获取在特定日期之后创建的所有'aaaa'行.例如:

AWS.config(access_key_id: 'xxx', secret_access_key: 'xxx', :dynamo_db => { :api_version => '2012-08-10' })
client = AWS::DynamoDB::Client.new
client.query(
{
  table_name: 'table',
  select: 'ALL_ATTRIBUTES',
  key_conditions: {
    'hk' => {
      comparison_operator: 'EQ',
      attribute_value_list: [
        {'s' => 'aaaa'}
      ]
    },
    'timestamp' => {
      comparison_operator: 'GE',
      attribute_value_list: …
Run Code Online (Sandbox Code Playgroud)

ruby amazon-web-services amazon-dynamodb

10
推荐指数
1
解决办法
1万
查看次数