This page explains how to use the array_select_dict function in APL.
array_select_dict
function in APL allows you to retrieve a dictionary from an array of dictionaries based on a specified key-value pair. This function is useful when you need to filter arrays and extract specific dictionaries for further processing. If no match exists, it returns null
. Non-dictionary values in the input array are ignored.
Splunk SPL users
array_select_dict
function in APL is similar to filtering objects in an array based on conditions in Splunk SPL. However, unlike Splunk, where filtering often applies directly to JSON structures, array_select_dict
specifically targets arrays of dictionaries.ANSI SQL users
array_select_dict
function applies a similar concept to array elements, allowing you to extract dictionaries from arrays using a condition.Name | Type | Description |
---|---|---|
array | dynamic | Input array of dictionaries. |
key | string | Key to match in each dictionary. |
value | scalar | Value to match for the specified key. |
null
. Non-dictionary elements in the array are ignored.
array_select_dict
to extract a dictionary where the key service.name
has the value frontend
.
Query
{"service.name": "frontend", "status_code": "200"}
This query selects the first dictionary in the array where service.name
equals frontend
and returns it.