Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services DynamoDB-查询范围键的最大值_Amazon Web Services_Amazon Dynamodb_Secondary Indexes - Fatal编程技术网

Amazon web services DynamoDB-查询范围键的最大值

Amazon web services DynamoDB-查询范围键的最大值,amazon-web-services,amazon-dynamodb,secondary-indexes,Amazon Web Services,Amazon Dynamodb,Secondary Indexes,我有一个DynamoDB表,它的结构如下 HK | RK | A1 | A2 | A3 (Hash Key) | (Range Key) 我有一个本地二级索引,其范围键为A3 我想找出特定的散列键HK,属性A3的最大值是多少。所以我像这样查询二级索引: Map<String, AttributeValue> eav = new HashMap<>(); eav.put(":v1", new AttributeValu

我有一个DynamoDB表,它的结构如下

    HK      |    RK      |   A1   |   A2  |   A3
(Hash Key)  | (Range Key)
我有一个本地二级索引,其范围键A3

我想找出特定的散列键HK,属性A3的最大值是多少。所以我像这样查询二级索引:

Map<String, AttributeValue> eav = new HashMap<>();
eav.put(":v1", new AttributeValue().withS("hash value"));
queryExpression = new DynamoDBQueryExpression<Table>()
        .withIndexName("index-name")
        .withKeyConditionExpression("HK = :v1")
        .withExpressionAttributeValues(eav)
        .withScanIndexForward(false);  //This will sort the result in descending order (w.r to range key)

queryExpression.setLimit(1);
myCollection = dynamoDBMapper.query(Table.class, queryExpression);
Map eav=newhashmap();
eav.put(“:v1”,新的AttributeValue()。带有(“哈希值”);
queryExpression=new DynamoDBQueryExpression()
.withIndexName(“索引名”)
.withKeyConditionExpression(“HK=:v1”)
.带有表达式属性值(eav)
.使用CANINDEXFORWARD(假)//这将按降序对结果进行排序(从w.r到范围键)
queryExpression.setLimit(1);
myCollection=dynamoDBMapper.query(Table.class,queryExpression);
问题在于,它返回所有带有指定哈希键的记录,并按范围键(A3)进行反向排序。我想独自拿第一张唱片。(给定香港A3值最大的记录)

我尝试使用setLimit,但它不起作用


如何实现这一点。

我使用
queryPage
而不是
query

QueryResultPage<Lookup> res = dynamoDBMapper.queryPage(Table.class, queryExpression);
QueryResultPage res=dynamoDBMapper.queryPage(Table.class,queryExpression);
更多信息