Complete the code to create a sparse index by specifying the attribute to index.
KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }]The sparse index uses the 'Category' attribute as the partition key to index only items that have this attribute.
Complete the code to define the projection type for the sparse index.
Projection: { ProjectionType: [1] }Using 'KEYS_ONLY' projection includes only the index keys in the index, which is common for sparse indexes to save space.
Fix the error in the attribute definition for the sparse index.
AttributeDefinitions: [{ AttributeName: 'Category', AttributeType: [1] }]The 'Category' attribute is a string, so its type must be 'S' for string in DynamoDB.
Fill both blanks to complete the sparse index creation with correct key schema and projection.
GlobalSecondaryIndexes: [{ IndexName: 'CategoryIndex', KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }], Projection: { ProjectionType: [2] } }]The sparse index uses 'Category' as the partition key and 'KEYS_ONLY' projection to index only items with 'Category' attribute efficiently.
Fill all three blanks to define a sparse index with attribute definitions, key schema, and projection type.
AttributeDefinitions: [{ AttributeName: [1], AttributeType: [2] }], GlobalSecondaryIndexes: [{ IndexName: 'CategoryIndex', KeySchema: [{ AttributeName: [3], KeyType: 'HASH' }], Projection: { ProjectionType: 'KEYS_ONLY' } }]The sparse index uses 'Category' as the attribute name with type 'S' (string) in attribute definitions and as the partition key in the key schema.