objectArray:eval()
function iterates over the values
of a nested array, applies the function on each element, and returns
results in a new array field. Currently, the function supports only flat
arrays as the output.
Although objectArray:eval()
can be used on both flat
arrays and nested arrays, then for best performance, we recommend using
objectArray:eval()
only for nested arrays (for
example JSON structures). For flat arrays, the
array:eval()
function is a recommended equivalent.
For a list of functions that can be used on flat arrays, see
Array Query Functions.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
array [a] | string | required | The array name in LogScale Array Syntax, for example, for events with fields incidents[0], incidents[1], ... this would be incidents[] , as in objectArray:eval(array="incidents[]", ... . | |
asArray | string | required | value passed to the array parameter | The output array — cannot be the same as the input array. |
function | non-aggregate function | required | The function applied to each element of the array. This argument is used to write a value to the same field that is given as the output array in the asArray argument. In objectArray:eval() Examples, such a field is _mapped. | |
var | string | optional[b] | input array name | Name of the variable to use in the function argument. |
[b] Optional parameters use their default value unless explicitly set. |
When using this function:
The variable defined by the
var
argument is validated to ensure it does not contain object/array access patterns, for example,[..]
or.
.The variable becomes available as a "pseudo-field" (meaning that it's not like a proper field in the event) in the
function
argument (seeobjectArray:eval()
Examples).The "pseudo-field" can access structured data on the array entries using an array access pattern consisting of
[number]
for array indexing and.
for sub-selections of object fields. These can be repeated/combined arbitrarily; for example,x.foo[0].bar.baz
is a valid pattern.The mapping between input and output array entries is done by the
function
argument: for each input array entry,function
maps an output array entry. The output/result value offunction
is the value of the same field (without[]
) given by theasArray
argument.
objectArray:eval()
Examples
Click
next to an example below to get the full details.Concatenate Values From Two Nested Array Elements
Concatenate values from two nested array elements returning output in flat array
Format Values From Two Array Elements Using :
Format Values from Two Array Elements using : as a separator
Concatenate Multiple Values From Nested Array Elements
Concatenate multiple values from nested array elements using objectArray:eval()
function with concat()
Concatenate Values From Nested Array Elements
Concatenate deeply nested objects and arrays using objectArray:eval()
function with concat()
Concatenate Values From Deeply Nested Array Elements
Concatenate deeply nested objects and arrays using objectArray:eval()
function with itself
Concatenate Object Arrays Into Single Array
Concatenate one or more objects from object arrays into a single array and string