I\'m curious about these two secondary indexes and differences between them. It is hard to imagine how this looks like. And I think, this will help more people than just me.
These are the possible searches by index:
Hash and Range indexes of a table: These are the usual indexes of previous versions of the Amazon AWS SDK.
Global and Local indexes: These are 'additional' indexes created on a table, in addition to existing hash and range indexes of the table. Global index is similar to a hash. Range index behave similarly to the range index used with the hash of the table. In you entity model in your code, the getter must be annotated in this way:
For global indexes:
@DynamoDBIndexHashKey(globalSecondaryIndexName = INDEX_GLOBAL_RANGE_US_TS)
@DynamoDBAttribute(attributeName = PROPERTY_USER)
public String getUser() {
return user;
}
For range index associated to the global index:
@DynamoDBIndexRangeKey(globalSecondaryIndexName = INDEX_GLOBAL_RANGE_US_TS)
@DynamoDBAttribute(attributeName = PROPERTY_TIMESTAMP)
public String getTimestamp() {
return timestamp;
}
Besides, if you read a table by a Global index, it must be an Eventual read (not Consistent read):
queryExpression.setConsistentRead(false);