Hi Team,
We are using QueryEnhancedRequest for get items in table with limit but limit value is not considered in GSI index query it is return all items.
Please help us to solve this issue?
GSI :
PationKeyValue : 'YES'
SortKeyValue : Date in string format.
QueryConditional
Key startKey=Key.builder().partitionValue(Messages.YES.getCode()).sortValue(startDate).build();
Key endKey=Key.builder().partitionValue(Messages.YES.getCode()).sortValue(endDate).build();
QueryConditional queryConditional = QueryConditional.sortBetween(startKey, endKey);
Expression expressions= Expression.builder().expression(expressionStr.toString()).expressionValues(filterParamMap).build();
QueryEnhancedRequest.Builder queryRequest = QueryEnhancedRequest.builder()
.queryConditional(queryConditional)
.filterExpression(expressions)
.scanIndexForward(false).limit(baseRequest.getLimit());
SdkIterable<Page<Records>> recordsListIterable =dynamoDbRecordTable.index("ByScheduleDate").query(queryRequest.build());
recordsListIterable.stream().forEach(rec -> {
totalRecordsList.addAll(rec.items());
});
Above code is not considered limit conditions and return all table items.