Filtering by a composite primary key
A composite key supports searching for a specific value in the hash attribute, and can include searching on the range attribute as well. Searching on both attributes narrows a search. When a composite primary key is defined for a table, Amazon DynamoDB uses its Query API to search on the key index only. This type of search is typically efficient.
If you select a table that uses a composite primary key, the query page of the data set editor displays the Searchable by Composite Key option, as shown in
Figure 7‑3. This option is disabled if the selected table uses a hash primary key.
Figure 7‑3 Query page displaying the Searchable by Composite Key option
In this example, the hash attribute is ForumName and the range attribute is Subject. You can select one or both of these attributes on which to filter. Each attribute you select creates a corresponding data set parameter, as shown in
Figure 7‑4.
Figure 7‑4 Data set parameters associated with the selected attributes in the composite primary key
You must edit each data set parameter to specify the attribute value to search.
Figure 7‑5 shows searching for the value Amazon DynamoDB in the ForumName hash attribute.
Figure 7‑5 Parameter value specified for an attribute in a composite primary key