表達式語言還引入了一組函式來查詢集合。
這些功能在下面說明。 在以下示例中,讓我們使用包含集合的事件負載:
{
"_experience":{
"campaign":{
"message":{
"profile":{
"pushNotificationTokens":[
{
"token":"token_1",
"application":{
"_id":"APP1",
"name":"MarltonMobileApp",
"version":"1.0"
}
},
{
"token":"token_2",
"application":{
"_id":"APP2",
"name":"MarketplaceApp",
"version":"1.0"
}
},
{
"token":"token_3",
"application":{
"_id":"APP3",
"name":"VendorApp",
"version":"2.0"
}
}
]
}
}
}
},
"timestamp":"1536160728"
}
函式"all(<condition>
)"
的 全部 函式通過使用布爾表達式來啟用給定集合上的篩選器定義。
<listExpression>.all(<condition>)
例如,在所有應用用戶中,您可以使用IOS13(布爾表達式「app used ==IOS13」)獲取這些用戶。 此函式的結果是包含與布爾表達式匹配的項的篩選清單(例如:app user 1、app user 34、app user 432)。
在「資料源條件」活動中,您可以檢查 全部 函式為null或不為null。 您也可以將此 全部 與其他函式(如 計數。 有關詳細資訊,請參見 資料源條件活動。
範例 1:
我們要檢查用戶是否安裝了特定版本的應用程式。 為此,我們將獲得與版本為1.0的移動應用程式關聯的所有推送通知令牌。然後,我們用 計數 函式,檢查返回的令牌清單是否包含至少一個元素。
count(@{LobbyBeacon._experience.campaign.message.profile.pushNotificationTokens.all(currentEventField.application.version == "1.0").token}) > 0
結果是真的。
範例 2:
我們用 計數 函式,以檢查集合中是否存在推送通知令牌。
count(@{LobbyBeacon._experience.campaign.message.profile.pushNotificationTokens.all().token}) > 0
結果將是真的。
當 all() 函式為空,篩選器將返回清單中的所有元素。 但是,為了計算集合的元素數,不需要全部函式。
count(@{LobbyBeacon._experience.campaign.message.profile.pushNotificationTokens.token})
表達式的結果是 3。
範例 3:
在這裡,我們檢查過去24小時內是否有人未收到任何通信。 我們使用兩個基於集合中兩個元素的表達式來過濾從ExperiencePlatform資料源檢索到的體驗事件集合。 特別是,將事件的時間戳與 nowWithDelta 的子菜單。
count(#{ExperiencePlatform.MarltonExperience.experienceevent.all(
currentDataPackField.directMarketing.sends.value > 0 and
currentDataPackField.timestamp > nowWithDelta(-1, "days")).timestamp}) == 0
如果沒有與這兩個條件相匹配的體驗事件,則結果為true。
範例 4:
在此,我們要檢查某個人在過去7天內是否至少啟動了一次應用程式,以便例如觸發推式通知,邀請他們啟動教程。
count(
#{ExperiencePlatform.AnalyticsData.experienceevent.all(
nowWithDelta(-7,"days") <= currentDataPackField.timestamp
and currentDataPackField.application.firstLaunches.value > 0
)._id}) > 0
currentEventField 僅在操作事件集合和 currentDataPackField
操作資料源集合時。 處理使用 全部。 第一 和 最後我們
逐個循環。 currentEventField 和 currentDataPackField
與所環繞的元素相對應。
函式"first(<condition>
)和「last(<condition>
)"
的 第一 和 最後 函式還在返回滿足篩選器的清單的第一個/最後一個元素時啟用集合中篩選器的定義。
<listExpression>.first(<condition>)
<listExpression>.last(<condition>)
範例 1:
此表達式返回與版本為1.0的移動應用程式關聯的第一個推送通知令牌。
@{LobbyBeacon._experience.campaign.message.profile.pushNotificationTokens.first(currentEventField.application.version == "1.0").token
結果為"token_1"。
範例 2:
此表達式返回與版本為1.0的移動應用程式關聯的最後一個推送通知令牌。
@{LobbyBeacon._experience.campaign.message.profile.pushNotificationTokens.last(currentEventField.application.version == "1.0").token}
結果為"token_2"。
這些體驗事件從Adobe Experience Platform以反時間順序的集合來檢索,因此:
範例 3:
我們檢查DMA ID的第一個(最近的)Adobe Analytics事件(其值非零)是否具有等於602的值。
#{ExperiencePlatform.AnalyticsProd_EvarsProps.experienceevent.first(
currentDataPackField.placeContext.geo.dmaID > 0).placeContext.geo.dmaID} == 602
函式「at(<index>
)"
的 在 函式,可根據索引引用集合中的特定元素。
索引0是集合的第一個索引。
<listExpression>
.at(<index>
)
範例:
此表達式返回清單的第二個推送通知令牌。
@{LobbyBeacon._experience.campaign.message.profile.pushNotificationTokens.at(1).token}
結果為"token_2"。
其他示例
#{ExperiencePlatform.ExperienceEventFieldGroup.experienceevent. all(currentDataPackField._aepgdcdevenablement2.purchase_event.receipt_nbr == "10-337-4016").
_aepgdcdevenablement2.purchase_event.productListItems. all(currentDataPackField.SKU == "AB17 1234 1775 19DT B4DR 8HDK 762").name}
#{ExperiencePlatform.ExperienceEventFieldGroup.experienceevent.last(
currentDataPackField.eventType == "commerce.productListAdds").productListItems.last(currentDataPackField.priceTotal >= 150).name}