【发布时间】:2014-02-06 07:44:25
【问题描述】:
我开始使用 Amazon DynamoDB,但遇到了查询问题。
我有一个表 Dev_Testgame1_Mail 以 id 作为主哈希键并遵循三个全局二级索引,
- fromPlayerId(哈希键)
- toPlayerId(哈希键)+ isRead(范围键)
- toPlayerId (Hash Key) + endDate(Range Key)
我有上面的代码来做查询,
**DynamoDBMail hashKObject = new DynamoDBMail();
hashKObject.setToPlayerId(playerId);
Condition endDateRangeKeyCondition = new Condition();
//endDateRangeKeyCondition.withComparisonOperator(ComparisonOperator.NULL).withAttributeValueList(new AttributeValue().withB(Utils.convertDateToByteBuffer(DateUtil.getUtcDateTime())));
endDateRangeKeyCondition.withComparisonOperator(ComparisonOperator.NULL);
DynamoDBQueryExpression<DynamoDBMail> queryExpression = new DynamoDBQueryExpression<DynamoDBMail>();
queryExpression.withHashKeyValues(hashKObject).withRangeKeyCondition("endDate", endDateRangeKeyCondition);
queryExpression.withIndexName("gsi_tp_enddt").withLimit(pageSize).withScanIndexForward(false);
return dynamodbMapper.queryPage(DynamoDBMail.class, queryExpression, new DynamoDBMapperConfig(TableNameOverride.withTableNamePrefix(Utils.getDynamoDBTableNamePrefix(gameId, env))));**
我收到以下错误,
com.amazonaws.AmazonServiceException:状态代码:400,AWS 服务:AmazonDynamoDBv2,AWS 请求 ID:GUUBV24K2O40T276R9NNN0EKB7VV4KQNSO5AEMVJF66Q9ASUAAJG,AWS 错误代码:ValidationException,AWS 错误消息:全局二级索引不支持一致读取
非常感谢您在此问题上的帮助。
谢谢 阿伦
【问题讨论】:
标签: amazon-dynamodb