Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
393 views
in Technique[技术] by (71.8m points)

java - Fetch n latest records from Dynamo DB

I am having a dynamo db with a GSI on GSI_ID and range key on lastUpdatedId attribute. I want only 1 task to be rendered which is the latest on the basis of match. This is the expression I am using

DynamoDBQueryExpression<Record> exp =
                new DynamoDBQueryExpression<GoldDataRecord>()
                        .withIndexName(GSI_ID)
                        .withKeyConditionExpression(KEY_EXP)
                        .withExpressionAttributeValues(attrValues)
                        .withLimit(1)
                        // to get the results in descending order of last updated date giving the latest data first
                        .withScanIndexForward(false)
                        .withSelect(Select.ALL_ATTRIBUTES)
                        .withConsistentRead(false);

private DynamoDBMapper dynamoDBMapper;
PaginatedQueryList<Record> res = dynamoDBMapper.query(Record.class, exp);

But it is fetching all the records that are matching the GSI. What am I doing wrong here?

question from:https://stackoverflow.com/questions/65917329/fetch-n-latest-records-from-dynamo-db

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...