PPL Lambda 関数 - Amazon OpenSearch Service

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

PPL Lambda 関数

注記

このPPL関数をサポートする AWS データソース統合を確認するには、「」を参照してください関数

EXISTS

使用法: Lambda 述語が配列内の 1 つ以上の要素を保持するかどうかexists(array, lambda)を評価します。

引数タイプ: ARRAY、 LAMBDA

戻り値タイプ: BOOLEAN。配列内の少なくとも 1 つの要素が Lambda 述語を満たすTRUE場合は を返し、それ以外の場合は を返しますFALSE

例:

os> source=people | eval array = json_array(1, -1, 2), result = exists(array, x -> x > 0) | fields result fetched rows / total rows = 1/1 +-----------+ | result | +-----------+ | true | +-----------+ os> source=people | eval array = json_array(-1, -3, -2), result = exists(array, x -> x > 0) | fields result fetched rows / total rows = 1/1 +-----------+ | result | +-----------+ | false | +-----------+

FILTER

使用法: は、指定された Lambda 関数を使用して入力配列をfilter(array, lambda)フィルタリングします。

引数タイプ: ARRAY、 LAMBDA

戻り値タイプ: ARRAY。Lambda 述語を満たす入力配列内のすべての要素ARRAYを含む 。

例:

os> source=people | eval array = json_array(1, -1, 2), result = filter(array, x -> x > 0) | fields result fetched rows / total rows = 1/1 +-----------+ | result | +-----------+ | [1, 2] | +-----------+ os> source=people | eval array = json_array(-1, -3, -2), result = filter(array, x -> x > 0) | fields result fetched rows / total rows = 1/1 +-----------+ | result | +-----------+ | [] | +-----------+

TRANSFORM

使用法: Lambda transform(array, lambda)変換関数を使用して配列内の要素を変換します。2 番目の引数は、バイナリ Lambda 関数を使用する場合の 要素のインデックスを示します。これは、機能プログラミングmapの に似ています。

引数タイプ: ARRAY、 LAMBDA

戻り値タイプ: ARRAY。Lambda 変換関数を入力配列の各要素に適用した結果ARRAYを含む 。

例:

os> source=people | eval array = json_array(1, 2, 3), result = transform(array, x -> x + 1) | fields result fetched rows / total rows = 1/1 +--------------+ | result | +--------------+ | [2, 3, 4] | +--------------+ os> source=people | eval array = json_array(1, 2, 3), result = transform(array, (x, i) -> x + i) | fields result fetched rows / total rows = 1/1 +--------------+ | result | +--------------+ | [1, 3, 5] | +--------------+

REDUCE

使用法: Lambda 関数を適用することで、配列を 1 つの値にreduce(array, start, merge_lambda, finish_lambda)減らします。関数は merge_lambda を開始値とすべての配列要素に適用し、次に finish_lambdaを結果に適用します。

引数タイプ: ARRAY、ANY、LAMBDA、 LAMBDA

戻り値タイプ: ANY。Lambda 関数を開始値と入力配列に適用した最終結果。

例:

os> source=people | eval array = json_array(1, 2, 3), result = reduce(array, 0, (acc, x) -> acc + x) | fields result fetched rows / total rows = 1/1 +-----------+ | result | +-----------+ | 6 | +-----------+ os> source=people | eval array = json_array(1, 2, 3), result = reduce(array, 10, (acc, x) -> acc + x) | fields result fetched rows / total rows = 1/1 +-----------+ | result | +-----------+ | 16 | +-----------+ os> source=people | eval array = json_array(1, 2, 3), result = reduce(array, 0, (acc, x) -> acc + x, acc -> acc * 10) | fields result fetched rows / total rows = 1/1 +-----------+ | result | +-----------+ | 60 | +-----------+