Querying a Global Secondary Index using the AWS SDK for .Net
Now, we are going to see how to query a Global Secondary Index.
Getting ready
To perform this operation, you can use the IDE of your choice. To perform a query operation, you should first add items using the AWS Console or SDK, as we have seen in the earlier chapters.
How to do it…
The Query API on the Global Secondary Index is similar to the Query API on a DynamoDB table. Perform the following operations in order to query the index:
Initiate the DynamoDB client with the credentials:
client = new AmazonDynamoDBClient();
Create an instance of
QueryRequest
, specifying the keys of items you wish to fetch from the secondary index. Here, we want to fetch the item whose hash keyname
isS3:
QueryRequest queryRequest = new QueryRequest { TableName = "product", IndexName = "NameManfrIndex", KeyConditionExpression = "#nm = :v_name", ExpressionAttributeNames = new Dictionary<String, String> { {"#nm", "name"} }...