【问题标题】:Kusto Query Language: Get keyword that was matched (has_any)Kusto 查询语言:获取匹配的关键字 (has_any)
【发布时间】:2021-08-25 06:22:50
【问题描述】:

我在我的 KQL 中提供一个 csv 文件作为外部数据源。我运行查询以匹配列:

Events | where Title has_any (ColumnName) | project Title, EventId

现在,我想将输出与匹配的列值连接起来。就像如果列有值: "test","test2","test3" 和 "test2" 在上面的查询中匹配,结果表应该是这样的:

Title,EventId,MatchedColumnValue

请帮忙

【问题讨论】:

    标签: azure azure-data-explorer kql kusto-explorer


    【解决方案1】:

    下面是使用has_any_index() 函数的方法:

    let Values = dynamic(["title1", "title2", "title3"]);
    let Events = datatable(EventId:int, Title:string)[1,"this is title2, and its boring", 2, "title3 is great", 3, "Nothing to find"];
    Events
    | extend Idx = has_any_index(Title, Values)
    | extend MatchedTitle = iif(Idx<0, "", tostring(Values[Idx]))
    | project-away Idx
    

    【讨论】:

    • 您正在使用 Values 数组的索引。长度未知或太长而无法输入。那么,我们如何在不明确提及索引的情况下做到这一点
    • 感谢 Dhruv 的坚持,我发现了一个“隐藏”功能,它完全符合您的要求。我更新了我的答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-08
    • 2023-01-13
    • 1970-01-01
    • 2013-07-14
    • 2022-01-23
    • 1970-01-01
    相关资源
    最近更新 更多