Dynamodb GSI With Limit is not supporting for QueryEnhancedRequest

0

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.

asked 3 months ago81 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions