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)