1 回答
- 最新
- 投票最多
- 评论最多
0
【以下的回答经过翻译处理】 您现在假设基表中的第二行将成为GSI中的第二行,但事实并非如此。基表中的项目按分区键分组并按排序键排序。而在GSI中,具有相同分区/排序键组合的多个项目可以具有多个项目,这意味着无法保证顺序。
至于您的问题,您在代码中将LEK
设置为空字符串,导致您错过了响应中的最后一条记录。尝试以下代码片段:
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('cust1')
customerID = 'bfbd221a-bc1f-4e96-943f-d809bb5e5af3'
startDate = '2022-06-14T17:42:36.830859+00:00'
endDate = '2022-06-16T18:52:40.044239+00:00'
def processItems(items):
print(items)
kwargs = {
'IndexName' : "my-index",
'KeyConditionExpression' : 'customer_id = :ci and transaction_time between :date1 and :date2',
'ExpressionAttributeValues' : {
':ci' : customerID,
':date1' : startDate,
':date2' : endDate,
},
'Limit' : 1,
'ScanIndexForward' : False
}
while True:
response = table.query( **kwargs )
processItems( response[ u'Items' ] )
if 'LastEvaluatedKey' in response:
kwargs[ 'ExclusiveStartKey' ] = response[ 'LastEvaluatedKey' ]
else:
break
相关内容
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 10 个月前