- 최신
- 최다 투표
- 가장 많은 댓글
Here's an example:
DynamoDbTable<Movie> moviesTable = enhancedClient.table("Movies", TableSchema.fromBean(Movie.class));
QueryConditional condition = QueryConditional.sortBetween(Key.builder()
.partitionValue(1958)
.sortValue("1920")
.build(), Key.builder()
.partitionValue(1958)
.sortValue("1950")
.build());
QueryEnhancedRequest request = QueryEnhancedRequest.builder()
.queryConditional(condition)
.scanIndexForward(false)
.build();
SdkIterable<Page<Movie>> movieWithName = moviesTable.index("my-index").query(request);
movieWithName.forEach(page-> {
List<Movie> allMovies = page.items();
for( Movie myMovie: allMovies){
System.out.println(myMovie.getTitle());
}
});
@Leeroy Hannigan , Thank you for your post and how to use limit here? and we trying use limit but getting all items.. please help me to fix this issue? and Most of person telling limit is not supported in QueryEnhancedRequest
QueryEnhancedRequest.Builder queryRequest = QueryEnhancedRequest.builder() .queryConditional(queryConditional) .filterExpression(expressions) .scanIndexForward(false) .limit(50);
SdkIterable<Page<Records>> recordsListIterable =dynamoDbRecordTable.index("ByScheduleDate").query(queryRequest.build());
Limit is supported, please ask a new question and I will answer it.
Hi @Leeroy Hannigan, We are tried with limit but query returns all items.
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(50);
SdkIterable<Page<Records>> recordsListIterable =dynamoDbRecordTable.index("ByScheduleDate").query(queryRequest.build());
recordsListIterable.stream().forEach(rec -> {
totalRecordsList.addAll(rec.items());
});
So i posted the questions here. Could you please hlep us?
Please ask a new question, and not post a question as an answer under someone else. https://repost.aws/questions/ask
관련 콘텐츠
- AWS 공식업데이트됨 2년 전
Hi @Leeroy Hannigan, Thank you for your quick response it is working as I expected It is very helpful