【问题标题】:Kibana - Pie-Chart with sum over two different fieldsKibana - 两个不同字段总和的饼图
【发布时间】:2017-06-16 17:28:38
【问题描述】:

在一个索引中我有两个映射。

"mappings" : {
    "deliveries" : {
        "properties" : {
            "@timestamp":  { "type" : "date", "format": "yyyy-MM-dd" },
            "receiptName" : { "type" : "text" },
            "amountDelivered" : { "type" : "integer" },
            "amountSold" : { "type" : "integer" },
            "sellingPrice" : { "type" : "float" },
            "earned" : { "type" : "float" }
        }
    },
    "expenses" : {
        "properties" : {
            "@timestamp":  { "type" : "date", "format": "yyyy-MM-dd" },
            "description": { "type" : "text" },
            "amount": { "type": "float" }
        }
    }
}

现在我想在 Kibana 中创建一个简单的饼图,用于汇总 deliveries.earnedexpenses.amount

这是可能的还是我必须切换到客户端应用程序?文档的数量(每月 2 或 3 个)真的要少到这里开始一些开发 xD

【问题讨论】:

    标签: elasticsearch kibana pie-chart


    【解决方案1】:

    您可以创建一个简单的scripted_field through Kibana,它将amountearned字段映射到同一个字段,称为transaction_amount

    无痛脚本:

    if(doc['earned'].length > 0) { return doc['earned']; } else { return doc['amount']; }
    

    然后您可以创建一个 饼图,其中 “Slice Size” 配置为 transaction_amount“Split Slices”之和 配置为 _type 上的 术语聚合

    【讨论】:

    • 你能再看看这个答案吗?您是说这些字段将映射到 transaction_amount,但我在代码中没有看到这一点。
    • 你说得对,实际的映射本身是通过 kibana UI 进行的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    • 1970-01-01
    相关资源
    最近更新 更多