在我的Android应用中,我想查询DynamoDB中的数据 . 将有一千个匹配的项目,但我只想获得它们中的前十个 . 我不知道如何设置这个限制 . 我在文档中找到了这些行:
DynamoDB查询和扫描API允许限制值限制结果的大小 .
在请求中,将Limit参数设置为您希望DynamoDB在返回结果之前处理的项目数 .
In a response, DynamoDB returns all the matching results within the scope of the Limit value. For example, if you issue a Query or a Scan request with a Limit value of 6 and without a filter expression, DynamoDB returns the first six items in the table that match the specified key conditions in the request (or just the first six items in the case of a Scan with no filter). If you also supply a FilterExpression value, DynamoDB will return the items in the first six that also match the filter requirements (the number of results returned will be less than or equal to 6).
但我找不到设定响应限制的方法 . 我找到了QueryResult的方法SetCount:
QueryResult result2 = dynamodb.query(request);
result2.setCount(5);
它说: then Count is the number of items returned after the filter was applied
但我认为这不是我想要的 . 因为DynamoDb在调用setCount之前仍会返回所有匹配项 . 谁能帮我?