某個 Lambda 函式會在 DynamoDB 資料表中搜尋項目,該資料表使用 email_address 作為分割區索引鍵,並儲存 customer_type、name 和 job_title 等屬性。當使用者在 customer_type 文字欄位中輸入內容時,此函式會觸發,並應針對給定的 customer_type 傳回 email_address 的部分符合項目。開發人員無法重新建立資料表。若要支援每個 customer_type 的部分 email_address 比對,應怎麼做?
選擇一個答案
點擊一個選項來檢查您的答案。
正確答案: 建立一個全域次要索引 (GSI),其中 customer_type 作為分割區索引鍵,email_address 作為排序索引鍵。使用 email_address 上的 begins_with 條件查詢 GSI。.
為什麼這是答案
正確答案是建立一個全域次要索引 (GSI),其中 customertype 作為分割區索引鍵,emailaddress 作為排序索引鍵,並使用 emailaddress 上的 beginswith 條件查詢 GSI。這是因為原始資料表的主鍵是 emailaddress,無法直接在 customertype 上進行有效查詢或部分比對。GSI 允許您定義不同於主表的分割區鍵和排序鍵,因此可以將 customertype 設定為 GSI 的分割區鍵,以支援依 customertype 進行查詢。將 emailaddress 設定為排序鍵,則可以利用 beginswith 條件來實現部分比對。 其他選項不正確的原因: 將 emailaddress 作為 GSI 的分割區索引鍵會導致無法依 customertype 查詢。 本機次要索引 (LSI) 必須與主表具有相同的分割區索引鍵,這不符合依 customertype 查詢的需求。 LSI 必須與主表具有相同的分割區索引鍵,且將 jobtitle 作為分割區索引鍵不符合依 customertype 查詢的需求。
通過考試 — 無需無休止地尋找答案
集中一處獲取此考試的所有核實題目和解釋,節省數小時的準備時間。1,000 多種認證 · 20 多種語言 · 免費開始。
更快通過您的考試 → 無需信用卡