物件類型對應範例 - Amazon Connect

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

物件類型對應範例

產生設定檔的物件類型對應

下列範例顯示填入標準設定檔的資料。

以下是傳入的物件:

{ "account": 1234, "email": "john@examplecorp.com", "address": { "address1": "Street", "zip": "Zip", "city": "City" }, "firstName": "John", "lastName": "Doe" }

下列程式碼展示傳入物件對映到標準設定檔物件,並針對 PersonalEmailAddressfullNameaccountId (唯一索引鍵) 建立索引。

{ "Fields": { "accountId": { "Source": "_source.account", "Target": "_profile.AccountNumber", "ContentType": "NUMBER" }, "shippingAddress.address1": { "Source": "_source.address.address1", "Target": "_profile.ShippingAddress.Address1" }, "shippingAddress.postalCode": { "Source": "_source.address.zip", "Target": "_profile.ShippingAddress.PostalCode" }, "shippingAddress.city": { "Source": "_source.address.city", "Target": "_profile.ShippingAddress.City" }, "personalEmailAddress": { "Source": "_source.email", "Target": "_profile.PersonalEmailAddress", "ContentType": "EMAIL_ADDRESS" }, "fullName": { "Source": "{{_source.firstName}} {{_source.lastName}}" }, "firstName": { "Source": "_source.firstName", "Target": "_profile.FirstName" }, "lastName": { "Source": "_source.lastName", "Target": "_profile.LastName" } }, "Keys": { "_email": [ { "FieldNames": ["personalEmailAddress"] } ], "_fullName": [ { "FieldNames": ["fullName"] } ], "_account": [ { "StandardIdentifiers": ["PROFILE","UNIQUE"], "FieldNames": ["accountId"] } ] } }

請注意,emailfullname 已編製索引,但它們不會用於搜尋設定檔。該帳戶是唯一索引鍵。需要指定物件。每當擷取具有相同帳戶 ID 的物件時,它都會以相同的帳號 ID 覆寫先前的物件。

標準設定檔物件中會填入數個欄位 (請參閱已定義 Target 的欄位)。

不填入標準設定檔的物件類型對應

此範例顯示更複雜的使用案例。它會擷取與設定檔相關的資料,但不一定會填入標準設定檔物件。

以下是傳入的物件:

{ "email": "john@examplecorp.com", "timestamp": "2010-01-01T12:34:56Z", "subject": "Whatever this is about", "body": "Body of ticket" }

以下是對應此資料的一種方法:

{ "Fields": { "email": { "Source": "_source.email", "ContentType": "EMAIL_ADDRESS" }, "timestamp": { "Source": "_source.timestamp" } }, "Keys": { "_email": [ { "StandardIdentifiers": ["PROFILE","LOOKUP_ONLY"], "FieldNames": ["email"] } ], "ticketEmail": [ { "StandardIdentifiers": ["PROFILE","SECONDARY","NEW_ONLY"], "FieldNames": ["email"] } ], "uniqueTicket": [ { "StandardIdentifiers": ["UNIQUE"], "FieldNames": ["email","timestamp"] } ] } }

此範例會擷取資料,並在第一次查詢時擷取電子郵件地址。

  • 如果電子郵件地址與單一設定檔相符,則會用來將資料附加至該特定設定檔。票證的唯一識別符由電子郵件和時間戳組成,因為沒有其他唯一識別符存在。

  • 如果指定的電子郵件中沒有設定檔,則會建立一個新的設定檔,並填入單一欄位 EmailAddress。擷取的物件會附加至此新的推論設定檔。可以找到設定檔的兩個可搜尋索引鍵是 _emailuniqueTicket

  • 如果指定的電子郵件地址存在多個設定檔,則會建立新的設定檔,以單一 EmailAddress 欄位填入,並將物件附加至此新設定檔。除了 _emailuniqueTicket 之外,此設定檔建立時還會定義 ticketEmail 索引鍵。該電子郵件中的任何後續票證都會指派給此一新的推斷設定檔。原因是 _email 索引鍵參照到三個設定檔,因此被丟棄,但是 ticketEmail 索引鍵僅參照單一設定檔 (新的推斷設定檔),並且仍然有效。

  • 在建立新的推論設定檔的情況下,會從建立該設定檔的第一個物件填入 EmailAddress 欄位。