"userId"にグローバルセカンダリインデックスを持つ "product"という名前のDynamoDBテーブルがあります。プライマリキーは "id"です。 "userID" GSIで "withExclusiveStartKey"を使用してページネーションを使用してクエリを実装しようとしています。私は、有効なlastIdを渡すとき はしかし、私は例外を以下の取得:AmazonDynamoDBv2;ステータスコード:DyanmoDB:グローバルセカンダリインデックスのwithExclusiveStartKeyを使用したページ分割
独占スタートキーは、テーブルのキースキーマ (サービスとして同じサイズでなければなりません400;エラーコード: にValidationException;リクエストID: 822db97e-04a3-4c36-8c72-6008e2693679)
は、私はここで間違って何をしているのですか?
public QueryResultPage<Product> findPaged(String userId,int limit,String lastId) {
DynamoDBMapper mapper = new DynamoDBMapper(dynamoDb);
Map<String, AttributeValue> vals = new HashMap<>();
vals.put(":valUserId", new AttributeValue().withS(userId));
DynamoDBQueryExpression<Product> queryExp = new DynamoDBQueryExpression<Product>()
.withKeyConditionExpression("userId = :valUserId")
.withIndexName(ModelConsts.TBL_PRODUCT_GSI_USERID)
.withExpressionAttributeValues(vals)
.withScanIndexForward(false)
.withConsistentRead(false)
.withLimit(limit);
if (lastId != null) {//paging
Map<String, AttributeValue> exclusiveStartKey = new HashMap<String, AttributeValue>();
exclusiveStartKey.put("id", new AttributeValue().withS(lastId));
queryExp = queryExp.withExclusiveStartKey(exclusiveStartKey);
}
QueryResultPage<Product> result = mapper.queryPage(Product.class, queryExp);
return result;
}