A Lambda function searches items in a DynamoDB table that uses email_address as the partition key and stores attributes like customer_type, name, and job_title. The function triggers as users type into a customer_type text field and should return partial matches for email_address for a given customer_type. The developer cannot recreate the table. What should be done to support partial email_address matching per customer_type?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a global secondary index (GSI) with customer_type as the partition key and email_address as the sort key. Query the GSI using a begins_with condition on email_address..
Why this is the answer
The correct solution is to create a Global Secondary Index (GSI) with customertype as the partition key and emailaddress as the sort key. This allows efficient querying for a specific customertype and then using the beginswith condition on the emailaddress sort key to find partial matches. The second option is incorrect because making emailaddress the partition key of the GSI would not allow efficient filtering by customertype first. The third option is incorrect because a Local Secondary Index (LSI) must share the same partition key as the base table, which is emailaddress in this scenario, not customertype. The fourth option is incorrect because it uses jobtitle as the partition key, which is not relevant to the primary filtering requirement of customertype.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed