I'm using the v2 aws DynamoDV Java sdk, and I want to limit the number of results that are returned when querying by the partition key (code snippet below), but the code below returns the full set of items back.
The java docs say "Note:The limit does not refer to the number of items to return, but how many items the database should evaluate while executing the query. Use limit together with Page.lastEvaluatedKey() and exclusiveStartKey in subsequent query calls to evaluate limit items per call." which seems to support the behavior I'm seeing.
However, How to set limit of matching items returned by DynamoDB using Java? has a solution using the .withMaxResultSize method in an earlier version of the sdk.
Does the java dynamodb v2 skd have something similar, or will I have to limit the result set manually? Code looks like:
QueryConditional conditional = QueryConditional.keyEqualTo(
Key.builder()
.partitionValue(jobId)
.build()
);
QueryEnhancedRequest request = QueryEnhancedRequest.builder()
.queryConditional(conditional)
.limit(1)
.scanIndexForward(false)
.build();