DynamoDB で Global secondary Index を使った検索クエリ

DynamoDBMapper mapper = new DynamoDBMapper(client);

// 検索条件
Condition condition = new Condition();
condition.withComparisonOperator(ComparisonOperator.LT);
condition.withAttributeValueList(new AttributeValue().withN(String.valueOf(System.currentTimeMillis())));

Item item = new Item();
item.setKey("1000");

DynamoDBQueryExpression<Item> expression = new DynamoDBQueryExpression<Item>();
// インデックス指定
expression.withIndexName("IndexName");
// Hash キーの指定
expression.withHashKeyValues(item);
expression.withConsistentRead(false);
// Range キーの指定
expression.withRangeKeyCondition("exiredDate", condition);
expression.withLimit(100);

PaginatedQueryList<DynamoSessionItem> sessions = mapper.query(Item.class, expression);