array_distinct
array_distinct 函数以列表形式返回所有不同的值。去重以生成去重后的列表是在截断之前进行的。
返回的元素数量上限取决于查询的运行位置:
- 搜索:将列表截断为最多 1,000 个随机元素。
- 信息中心和规则:将列表截断为最多 25 个随机元素。
| 语法 | 形参数据类型 | 返回值类型 |
|---|---|---|
array_distinct(expression) |
STRING |
LIST |
代码示例
返回不同的事件类型
返回包含不同事件类型的数组。
$event_type = metadata.event_type outcome: $event_type_array = array_distinct($event_type)从不同的数组中排除默认值
以下示例会过滤掉缺少安全结果说明的事件。它在重复字段上使用 any 关键字,以在结果聚合期间保留所有数组索引:
events: $e.security_result[0].description != "" any $e.security_result.description = "" outcome: $security_result_description = array_distinct($e.security_result.description)