I have a DynamoDB table where 2 GSIs have the same hash key but different range key. I am not getting how should I represent 2 index names (globalSecondaryIndexName) in in the @DynamoDBIndexHashKey
attribute -
Table
entityid<br/>
placeid<br/>
starttime<br/>
endtime<br/>
GSI 1 - hashkey : placeid, rangekey : starttime<br/>
GSI 2 - hashkey : placeid, rangekey : endtime
@DynamoDBIndexHashKey( attributeName = "placeid" globalSecondaryIndexName= "placeid-starttime-index" )<br>
private String placeid;
How can I specify the second index name here?
Querying a Global Secondary IndexThe query must specify the name of the base table and the name of the index that you want to use, the attributes to be returned in the query results, and any query conditions that you want to apply. DynamoDB can return the results in ascending or descending order.
Each table in DynamoDB can have up to 20 global secondary indexes (default quota) and 5 local secondary indexes.
Secondary indexes are a critical part of modeling your data in DynamoDB. With a secondary index, you can add additional access patterns to your application without the hassle of maintaining multiple copies of the same data. DynamoDB will handle all replication from the base table to your secondary index.
You have to specify the index names in a String array globalSecondaryIndexNames:
@DynamoDBIndexHashKey( attributeName = "placeid" globalSecondaryIndexNames={ "placeid-starttime-index","placeid-endtime-index"} )
private String placeid;
The @dynamodbindexhashkey annotation also takes an array for the index names.
Check below link for documentation.
http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/datamodeling/DynamoDBIndexHashKey.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With