リスト関数 list-functions

リスト関数を使用すると、ジャーニー式内で値のコレクションを操作して作業できます。 これらの関数は、カスタマージャーニーでの配列やリストのフィルタリング、並べ替え、変換、分析に不可欠です。

リスト関数は、次の操作が必要な場合に使用します。

  • 条件に基づいてコレクションから特定の項目をフィルタリングして抽出(filtergetListItem
  • リスト要素を昇順または降順に並べ替えて整理(sort
  • リストから重複を削除し、一意の値を取得(distinctdistinctWithNull
  • コレクション内に値が存在するかどうかを確認(in
  • リストから返される項目の数を制限(limit
  • リストのサイズを取得(listSize)またはリストを異なる形式に変換(serializeList
  • リスト間の共通エレメントの検索(intersect)、リストの結合(mergeLists)、別のリストからのリストの減算(differenceLists)などのセット操作を実行します

リスト関数は、複雑なデータ構造を操作するための強力なツールを提供し、コレクションの内容に基づいた高度なデータ操作と条件付きロジックを可能にします。

differenceLists differenceLists

2番目のリストに存在しない最初のリストの項目を返します(差分を設定:list 1 - list 2)。 Null エントリはスキップされます。 結果は常に重複する値を削除し、最初のリストの挿入順序を保持します。

構文
differenceLists(<parameters>)
パラメーター
table 0-row-3 1-row-3 2-row-3
パラメーター タイプ 説明
リスト 1 listString、listInteger、listDecimal、listBoolean、listDuration、listDateTime、listDateTimeOnly、listDateOnly 減算するリスト。
リスト 2 リスト 1と同じタイプです。 リスト 1から削除する項目のリスト。
シグネチャと戻り値のタイプ

differenceLists(listString,listString):listString

differenceLists(listInteger,listInteger):listInteger

differenceLists(listDecimal,listDecimal):listDecimal

differenceLists(listBoolean,listBoolean):listBoolean

differenceLists(listDuration,listDuration):listDuration

differenceLists(listDateTime,listDateTime):listDateTime

differenceLists(listDateTimeOnly,listDateTimeOnly):listDateTimeOnly

differenceLists(listDateOnly,listDateOnly):listDateOnly

code language-json
differenceLists(['a','b','c'], ['b'])

['a','c'] を返します。

code language-json
differenceLists(['a','a','b'], [])

['a','b'] を返します。

code language-json
differenceLists([], ['a'])

[] を返します。

distinct distinct

指定されたリストのユニークな値またはオブジェクトを返します。 null エントリは無視されます。

構文
distinct(<parameters>)
パラメーター
table 0-row-3 1-row-3 2-row-3
パラメーター タイプ 説明
listToProcess listString、listBoolean、listInteger、listDecimal、listDuration、listDateTime、listDateTimeOnly、listDateOnly、listObject のいずれか 処理するリスト。 listObject の場合は、フィールド参照にする必要があります。
keyAttributeName 文字列 このパラメーターはオプションで、listObject に対してのみ使用できます。 パラメーターを指定しないと、すべての属性の値が同じ場合、オブジェクトは重複していると見なされます。 パラメーターを指定していて、指定された属性が同じ値を持つ場合、オブジェクトは重複していると見なされます。
シグネチャと戻り値のタイプ

distinct(<listInteger>)

整数のリストを返します。

distinct(<listDecimal>)

小数のリストを返します。

distinct(<listString>)

文字列のリストを返します。

distinct(<listDateTimeOnly>)

タイムゾーンを考慮しない日時のリストを返します。

distinct(<listDateTime>)

日時のリストを返します。

distinct(<listDateOnly>)

日付のリストを返します。

distinct(<listBoolean>)

ブール値のリストを返します。

distinct(<listDuration>)

期間のリストを返します。

distinct(<listObject>)

distinct(<listObject>,<string>)

オブジェクトのリストを返します。

distinct([10,2,10,null])

[10, 2] を返します。

distinctWithNull distinctWithNull

指定されたリストのユニークな値またはオブジェクトを返します。 リストに null エントリが少なくとも 1 つ含まれる場合、返されるリストに null エントリが含まれます。

構文
distinctWithNull(<parameters>)
パラメーター
table 0-row-3 1-row-3
パラメーター タイプ 説明
listToProcess listString、listBoolean、listInteger、listDecimal、listDuration、listDateTime、listDateTimeOnly、listDateOnly 処理するリスト。
シグネチャと戻り値のタイプ

distinctWithNull(<listInteger>)

整数のリストを返します。

distinctWithNull(<listDecimal>)

小数のリストを返します。

distinctWithNull(<listString>)

文字列のリストを返します。

distinctWithNull(<listDateTimeOnly>)

タイムゾーンを考慮しない日時のリストを返します。

distinctWithNull(<listDateTime>)

日時のリストを返します。

distinctWithNull(<listDateOnly>)

日付のリストを返します。

distinctWithNull(<listBoolean>)

ブール値のリストを返します。

distinctWithNull(<listDuration>)

期間のリストを返します。

distinctWithNull([10,2,10,null])

[10, 2, null] を返します。

メモ:​パラメーター <listObject> は、この関数ではサポートされません。

filter filter

指定されたキー値の 1 つに一致するキー属性を持つオブジェクトで構成される listObject(オブジェクトリスト)を返します。

構文
filter(<parameters>)
パラメーター
table 0-row-3 1-row-3 2-row-3 3-row-3
パラメーター タイプ 説明
listToFilter listObject(オブジェクトリスト) フィルタリングの対象となるオブジェクトリスト。 フィールド参照にする必要があります。
keyAttributeName 文字列 指定されたリストのオブジェクト内の属性名。フィルタリングのキーとして使用されます
keyValueList リスト フィルタリングに使用するキー値の配列
シグネチャと戻り値のタイプ

filter(listObject, string, listString)

filter(listObject, string, listInteger)

filter(listObject, string, listDecimal)

filter(listObject, string, listDateTime)

filter(listObject, string, listDateTimeOnly)

filter(listObject, string, listDateOnly)

filter(listObject, string, listDuration)

filter(listObject, string, listBoolean)

listObject を返します。

受信イベント「myevent」で渡されるペイロードの例を次に示します。

code language-json
"productListItems": [{
   "id": "product1",
   "name": "the product 1",
   "price": 20
},{
   "id": "product2",
   "name": "the product 2",
   "price": 30
},{
   "id": "product3",
   "name": "the product 3",
   "price": 50
}]

次の式を使用できます。

code language-json
filter(
 @event{myevent.productListItems},
 "id",
 ["product2", "product3", "product4"]
)

「product2」と「product3」を id とする 2 つのオブジェクトから成る listObject を返します。

getListItem getListItem

指定されたインデックスのリスト項目を返します。

構文
getListItem(<parameters>)
パラメーター
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 8-row-2 9-row-2
パラメーター タイプ
リスト listString
リスト listBoolean
リスト listInteger
リスト listDecimal
リスト listDuration
リスト listDateTime
リスト listDateTimeOnly
リスト listDateOnly
index 整数
シグネチャと戻り値のタイプ

getListItem(<listInteger>,<index>)

整数を返します。

getListItem(<listDecimal>,<index>)

小数を返します。

getListItem(<listString>,<index>)

文字列を返します。

getListItem(<listDateTimeOnly>,<index>)

タイムゾーンを無視して日時を返します。

getListItem(<listDateTime>,<index>)

日時を返します。

getListItem(<listDateOnly>,<index>)

日付のリストを返します。

getListItem(<listBoolean>,<index>)

ブール値を返します。

getListItem(<listDuration>,<index>)

期間を返します。

getListItem([10, 2, 3], 1)

「2」を返します。

getListItem(["A", "B", "C"], 2)

「C」を返します。

値「20.45.2.3434」を持つイベントフィールド「event.appVersion」の例

split(@event{event.appVersion}, "\\.")

["20", "45", "2", "3434"] を返します

getListItem(split(@event{event.appVersion}, "\\."), 0)

「20」を返します

in in

最初の引数値がリストに含まれているかどうかを確認します。 確認は、各引数値に対して Equal を使用して実行されます。 引数の値が見つかった場合は true を返し、それ以外の場合は false を返します。

<expression> のタイプは、リストの項目と一致する必要があります。 なお、リストの項目のタイプは互いに一致する必要があります。

構文
in(<parameters>)
パラメーター
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 8-row-2 9-row-2 10-row-2 11-row-2 12-row-2 13-row-2 14-row-2 15-row-2
パラメーター タイプ
文字列 文字列
ブール ブール
整数 整数
小数 小数
期間 期間
日時 日時
日時のみ 日時のみ
リスト listString
リスト listBoolean
リスト listInteger
リスト listDecimal
リスト listDuration
リスト listDateTime
リスト listDateTimeOnly
リスト listDateOnly
シグネチャと戻り値のタイプ

in(<integer>,<listInteger>)

in(<decimal>,<listDecimal>)

in(<string>,<listString>)

in(<boolean>,<listBoolean>)

in(<dateTimeOnly>,<listDateTimeOnly>)

in(<dateTime>,<listDateTime>)

in(<dateOnly>,<listDateOnly>)

in(<duration>,<listDuration>)

ブール値を返します。

in(4,[4,5,3,4])

true を返します。

in(8,[4,5,3,4])

false を返します。

in(#{ExperiencePlatform.ProfileFieldGroup.profile.person.gender}, ["male"])

intersect intersect

2 つの入力リストで共通する値を返します。 2 つのリストのいずれかが null の場合、空のリストを返します。

構文
intersect(<parameters>)
パラメーター
table 0-row-2 1-row-2 2-row-2
パラメーター タイプ
リスト 1 リスト
リスト 2 リスト
シグネチャと戻り値のタイプ

intersect(listString,listString):listString

intersect(listDecimal,listDecimal):listDecimal

intersect(listInteger,listInteger):listInteger

intersect(listDateTime,listDateTime):listDateTime

intersect(listDateTimeOnly,listDateTimeOnly):listDateTimeOnly

intersect(listDateOnly,listDateOnly):listDateOnly

intersect(listDuration,listDuration):listDuration

intersect(listBoolean,listBoolean):listBoolean

リストを返します。

code language-json
intersect(
    ["sports", "news", "documentary"],
    ["sports", "movies", "documentary"]
)

[“sports”, “news”] を返します。

code language-json
intersect(
    #{ExperienceDataPlatform.profile.interests},
    ["sports", "documentary"]
)

プロファイル属性と指定されたカテゴリリストの間の共通項目を返します。

code language-json
intersect(
    #{ExperienceDataPlatform.profile.interests},
        @event{myEvent.sport_interests}
)

プロファイル属性と指定されたイベントフィールドの間の共通項目を返します。

limit limit

リストの先頭または末尾の N 個の要素を返します。

構文
limit(<parameters>)
パラメーター
table 0-row-3 1-row-3 2-row-3 3-row-3
パラメーター タイプ 説明
listToProcess listString、listBoolean、listInteger、listDecimal、listDuration、listDateTime、listDateTimeOnly、listDateOnly、listObject のいずれか 考慮するリスト。 listObject の場合は、フィールド参照にする必要があります。
numberOfItems 整数 指定されたリストから返される項目の数。
firstOrLastItems ブール値 このパラメーターはオプションです(デフォルトは true)。 true の場合は、先頭の項目を返します。 false の場合は、末尾の項目を返します。
シグネチャと戻り値のタイプ

limit(<listString>,<integer>)

limit(<listString>,<integer>,<boolean>)

文字列のリストを返します。

limit(<listInteger>,<integer>)

limit(<listInteger>,<integer>,<boolean>)

整数のリストを返します。

limit(<listDecimal>,<integer>)

limit(<listDecimal>,<integer>,<boolean>)

小数のリストを返します。

limit(<listBoolean>,<integer>)

limit(<listBoolean>,<integer>,<boolean>)

ブール値のリストを返します。

limit(<listDateOnly>,<integer>)

limit(<listDateOnly>,<integer>,<boolean>)

日付のリストを返します。

limit(<listDateTimeOnly>,<integer>)

limit(<listDateTimeOnly>,<integer>,<boolean>)

タイムゾーンを考慮しない日時のリストを返します。

limit(<listDateTime>,integer>)

limit(<listDateTime>,<integer>,<boolean>)

日時のリストを返します。

limit(<listDuration>,<integer>)

limit(<listDuration>,<integer>,<boolean>)

期間のリストを返します。

limit(<listObject>,<integer>)

limit(<listObject>,<integer>,<boolean>)

オブジェクトのリストを返します。

limit(["A", "B", "C", "D", "E"], 3)

["A","B","C"] を返します。

limit(["A", "B", "C", "D", "E"], 3, false)

["C","D","E"] を返します。

listSize listSize

リスト内の要素の数をカウントします。

構文
listSize(<parameters>)
パラメーター
table 0-row-3 1-row-3
パラメーター タイプ 説明
listToProcess listString、listBoolean、listInteger、listDecimal、listDuration、listDateTime、listDateTimeOnly、listDateOnly、listObject のいずれか 処理するリスト。 listObject の場合は、フィールド参照にする必要があります。 listObject に null オブジェクトを含めることはできません。
シグネチャと戻り値のタイプ

listSize(<listInteger>)

listSize(<listDecimal>)

listSize(<listString>)

listSize(<listBoolean>)

listSize(<listDateTimeOnly>)

listSize(<listDateTime>)

listSize(<listDateOnly>)

listSize(<listDuration>)

整数を返します。

listSize(<listObject>)

listSize([10,2,3])

3 を返します。

listSize(@event{my_event.productListItems})

指定されたオブジェクト配列内のオブジェクト数を返します(listObject 型)。

mergeLists mergeLists

2つのリストを組み合わせる。 deduplicatetrueの場合、重複する値が削除された2つのリストの和集合を返します。 deduplicatefalseの場合、2つのリスト (リスト 1のアイテムの後にリスト 2のアイテムが続く)の連結を返し、重複を保持します。 Null エントリはスキップされます。

注意: deduplicate パラメーターは、動的なブール式ではなく、リテラル trueまたはfalseである必要があります。

構文
mergeLists(<parameters>)
パラメーター
table 0-row-3 1-row-3 2-row-3 3-row-3
パラメーター タイプ 説明
リスト 1 listString、listInteger、listDecimal、listBoolean、listDuration、listDateTime、listDateTimeOnly、listDateOnly 最初のリスト。 その項目は最初に結果に追加されます。
リスト 2 リスト 1と同じタイプです。 2つ目のリスト。 その項目は、リスト 1の項目の後に追加されます。
重複の除外 ブーリアンリテラル trueは、重複が削除された両方のリストの結合を返します。 falseは、重複を保持しながら、両方のリストの連結を返します。 リテラル trueまたはfalseである必要があります。
シグネチャと戻り値のタイプ

mergeLists(listString,listString,boolean):listString

mergeLists(listInteger,listInteger,boolean):listInteger

mergeLists(listDecimal,listDecimal,boolean):listDecimal

mergeLists(listBoolean,listBoolean,boolean):listBoolean

mergeLists(listDuration,listDuration,boolean):listDuration

mergeLists(listDateTime,listDateTime,boolean):listDateTime

mergeLists(listDateTimeOnly,listDateTimeOnly,boolean):listDateTimeOnly

mergeLists(listDateOnly,listDateOnly,boolean):listDateOnly

code language-json
mergeLists(['a','b'], ['b','c'], true)

['a','b','c'] を返します。

code language-json
mergeLists(['a','b'], ['b','c'], false)

['a','b','b','c'] を返します。

serializeList serializeList

指定されたリスト(listObject 以外の任意の型)を文字列に変換します。

構文
serializeList(<parameters>)
パラメーター
table 0-row-3 1-row-3 2-row-3 3-row-3
パラメーター タイプ 説明
listToProcess listString、listBoolean、listInteger、listDecimal、listDuration、listDateTime、listDateTimeOnly、listDateOnly 文字列に変換するリスト。
区切り記号 文字列 出力文字列内の各リスト要素間の区切り記号。
addQuotes ブール値 このパラメーターは、出力文字列の各要素に引用符を含める(true)か、含まない(false)かを示します。
シグネチャと戻り値のタイプ

serializeList(<listInteger>,<string>,<boolean>)

serializeList(<listDecimal>,<string>,<boolean>)

serializeList(<listString>,<string>,<boolean>)

serializeList(<listBoolean>,<string>,<boolean>)

serializeList(<listDateTimeOnly>,<string>,<boolean>)

serializeList(<listDateTime>,<string>,<boolean>)

serializeList(<listDateOnly>,<string>,<boolean>)

serializeList(<listDuration>,<string>,<boolean>)

文字列を返します。

serializeList(["Hello","World"], " ", false)

「Hello World」を返します。

serializeList(["Hello", "World"], ",", true)

「“Hello”,“World”」を返します。

sort sort

値のリストやオブジェクトを自然な順序に並べ替えます。

構文
sort(<parameters>)
パラメーター
table 0-row-3 1-row-3 2-row-3 3-row-3
パラメーター タイプ 説明
listToSort listString、listBoolean、listInteger、listDecimal、listDuration、listDateTime、listDateTimeOnly、listDateOnly、listObject のいずれか 並べ替えるリスト。 listObject の場合は、フィールド参照にする必要があります。
keyAttributeName 文字列 このパラメーターは listObject に対してのみ使用します。 指定されたリストのオブジェクト内の属性名は、並べ替えのキーとして使用されます。
sortingOrder ブール値 昇順(true)または降順(false)
シグネチャと戻り値のタイプ

sort(<listInteger>,<boolean>)

整数のリストを返します。

sort(<listDecimal>,<boolean>)

小数のリストを返します。

sort(<listString>,<boolean>)

文字列のリストを返します。

sort(<listDateTimeOnly>,<boolean>)

タイムゾーンを考慮しない日時のリストを返します。

sort(<listDateTime>,<boolean>)

日時のリストを返します。

sort(<listDateOnly>,<boolean>)

日付のリストを返します。

sort(<listBoolean>,<boolean>)

ブール値のリストを返します。

sort(<listObject>,<string>,<boolean>)

オブジェクトのリストを返します。

sort(["A", "C", "B"], true)

["A","B","C"] を返します。

sort([1, 3, 2], false)

[3, 2, 1] を返します。

sort(@event{my_event.productListItems}, "SKU", true)

SKU 属性で並べ替えられた listObject を返します(昇順)

AI Knowledge Reference

This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.

For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.

  • TL;DR: This page documents all list functions available in AJO journey expressions, covering how to filter, sort, deduplicate, check membership, limit, serialize, merge, subtract, and find intersections of lists and arrays.

Intents:

  • Remove duplicate values from a list using distinct (ignoring nulls) or distinctWithNull (preserving nulls)
  • Filter a listObject to return only objects matching specific key values using filter
  • Retrieve an element at a specific index from a list using getListItem
  • Check whether a value exists in a list using in
  • Find common elements between two lists using intersect
  • Combine two lists, with or without deduplication, using mergeLists
  • Subtract one list from another (set difference) using differenceLists
  • Return the first or last N elements of a list using limit
  • Count the total number of elements in a list using listSize
  • Convert a list to a delimited string using serializeList
  • Sort a list in ascending or descending order using sort

Glossary:

  • listObject: A list of complex objects that must be a field reference; cannot contain null objects (product-specific)
  • keyAttributeName: An optional string parameter used with distinct, filter, and sort to identify which object attribute to use for deduplication, filtering, or sorting (product-specific)
  • intersect: A set operation returning only the elements present in both input lists
  • mergeLists: A set operation returning the union (deduplicated) or concatenation (with duplicates) of two lists, depending on the deduplicate parameter (product-specific)
  • differenceLists: A set operation returning the items of the first list that are not present in the second list (product-specific)

Guardrails:

  • distinctWithNull does not support the <listObject> parameter type
  • filter requires the listObject parameter to be a field reference, not an inline literal
  • listSize on a listObject requires the list to be a field reference; a listObject cannot contain null objects
  • serializeList does not support the listObject type
  • mergeLists and differenceLists only support scalar list types (string, integer, decimal, boolean, dateTime, dateTimeOnly, dateOnly, duration); listObject is not supported
  • mergeLists’s deduplicate parameter must be a literal true/false, not a dynamic boolean expression
  • differenceLists always deduplicates its result; there is no option to keep duplicates

Terminology:

  • Canonical name: List functions — Acronym: none — variants: collection functions, array functions
  • Synonyms: “listSize” = “count list elements”; “serializeList” = “join list to string”
  • Do not confuse: “distinct” (ignores nulls) ≠ “distinctWithNull” (preserves null as a distinct value)
  • Do not confuse: “limit” with third parameter true (returns first N items) ≠ “limit” with false (returns last N items)
  • Do not confuse: “intersect” (common elements between two lists) ≠ “filter” (elements matching specific key values)
  • Do not confuse: “mergeLists” (combines two lists, union or concatenation) ≠ “differenceLists” (subtracts one list from another) ≠ “intersect” (common elements only)

FAQ:

  • Q: How do I get the first 3 items of a list? — Use limit(myList, 3) or limit(myList, 3, true); the default is to return the first items.
  • Q: How do I get the last 3 items of a list? — Use limit(myList, 3, false).
  • Q: What is the difference between distinct and distinctWithNull?distinct ignores null values and excludes them from the result; distinctWithNull treats null as a distinct value and includes one null entry if any nulls are present.
  • Q: Can I filter a list of strings with filter? — No, filter only works on listObject; for scalar lists use in or distinct for deduplication.
  • Q: How do I check if a value is in a list? — Use in(value, myList), which returns true if the value is found in the list.
  • Q: Can I sort a listObject by a specific attribute? — Yes, use sort(@event{...}, "attributeName", true) where the second parameter is the attribute name and the third is the sort direction (true = ascending).
  • Q: How do I combine two lists and remove duplicates? — Use mergeLists(list1, list2, true).
  • Q: How do I combine two lists but keep duplicate values? — Use mergeLists(list1, list2, false).
  • Q: How do I find the items in one list that are not in another? — Use differenceLists(list1, list2), which returns the items of list1 not present in list2.
  • Q: What is the difference between intersect and differenceLists?intersect returns items common to both lists; differenceLists returns items in the first list that are absent from the second list.
recommendation-more-help
journey-optimizer-help