Reputation: 613
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?
Upvotes: 8
Views: 9839
Reputation: 119
DynamoDBIndexHashKey annotation accepts both single String value and array as index name into it's parameter.
**globalSecondaryIndexName** - Receives a String as index name. **globalSecondaryIndexNames** -Receives an array of index names.
So, you may set multiple index names as like below :
@DynamoDBIndexHashKey(attributeName = "placeid" globalSecondaryIndexNames={"placeid-starttime-index", "placeid-endtime-index"}) private String placeid;
Upvotes: 1
Reputation: 613
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;
Upvotes: 18
Reputation: 927
The @dynamodbindexhashkey annotation also takes an array for the index names.
Check below link for documentation.
Upvotes: 2