Step 7: Query the Global Secondary Index - Amazon DynamoDB

Step 7: Query the Global Secondary Index

In this step, you query a global secondary index on the Music table using the Amazon DynamoDB console or the AWS CLI.

For more information about global secondary indexes, see Using Global Secondary Indexes in DynamoDB.

Follow these steps to use the DynamoDB console to query data through the AlbumTitle-index global secondary index.

  1. Open the DynamoDB console at

  2. In the navigation pane on the left side of the console, choose Tables.

  3. Choose the Music table from the table list.

  4. Choose the Items tab for the Music table.

  5. In the drop-down list, choose Query.

                                Console screenshot showing the dropdown list with Query
                                    selected on the Items tab.
  6. In the drop-down list next to Query , choose [Index] AlbumTitle-index: AlbumTitle .

    For AlbumTitle, enter Somewhat Famous, and then choose Start search.

The following AWS CLI example queries a global secondary index AlbumTitle-index on the Music table.

aws dynamodb query \ --table-name Music \ --index-name AlbumTitle-index \ --key-condition-expression "AlbumTitle = :name" \ --expression-attribute-values '{":name":{"S":"Somewhat Famous"}}'

Using query returns the following sample result.

{ "Count": 1, "Items": [ { "AlbumTitle": { "S": "Somewhat Famous" }, "Awards": { "N": "1" }, "SongTitle": { "S": "Call Me Today" }, "Artist": { "S": "No One You Know" } } ], "ScannedCount": 1, "ConsumedCapacity": null }