【问题标题】:Kibana Bargraph not filtering data properlyKibana Bargraph 未正确过滤数据
【发布时间】:2020-09-21 05:44:57
【问题描述】:

我在索引“testfilter”中插入了以下数据集

POST /_bulk
{"index":{"_index":"testfilter"}}
{ "jobid": 1, "table_name": "table_A", "Tags": [ { "TagType": "WorkTypeA", "Tag": "ETL" }, { "TagType": "Subject Area", "Tag": "Telecom" } ] }
{"index":{"_index":"testfilter"}}
{ "jobid": 2, "table_name": "table_B", "Tags": [ { "TagType": "WorkTypeB", "Tag": "Engineering" }, { "TagType": "Subject Area", "Tag": "Telecom" } ] }
{"index":{"_index":"testfilter"}}
{ "jobid": 3, "table_name": "table_C", "Tags": [ { "TagType": "WorkTypeC", "Tag": "Development" }, { "TagType": "Subject Area", "Tag": "Telecom" } ] }

并且索引映射(GET testfilter/_mapping)如下

{
  "testfilter" : {
    "mappings" : {
      "properties" : {
        "Tags" : {
          "properties" : {
            "Tag" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "TagType" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        },
        "jobid" : {
          "type" : "long"
        },
        "table_name" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

当我通过选择 X Axis as 在 Kibana 中创建条形图可视化时:

Aggregation : Terms
Filed : Tags.Tag.keyword

图表得到正确构建。当我通过选择 Tag : Development 进行过滤时,我得到两个栏,一个过滤“Development”,另一个过滤“Telecom”(如图所示在屏幕截图中)

如何构建当我过滤任何标签时我应该只获得该标签数据的图表

【问题讨论】:

    标签: elasticsearch kibana elastic-stack elk kibana-7


    【解决方案1】:

    这可能是因为您在本文档中在字段 Tags.Tag 中存储了字符串列表。如果是这种情况,则说明 elasticsearch 运行正常。

    您需要了解 elasticsearch 聚合的工作原理。假设你在 elasticsearch 中插入了下面的 json

    {
      "Tags": {
        "tag": [
          "abc",
          "def"
        ]
      }
    }
    

    在您的可视化中,您点击了术语 abc。

    因此,后端的 elasticsearch 将触发查询并尝试汇总所有文档中存在的所有术语,其中“abc”存在于“Tags.Tag.keyword”字段中。

    因此,在您的情况下,具有术语发展的文档中可能还包含价值电信,因此它向您展示了这一点。

    【讨论】:

    • 这就是我试图强调的,但究竟什么是解决方案?
    • 你不能那样做。那是。 elasticsearch 如何在内部发挥作用。它是一个面向文档的搜索引擎,并在文档的基础上为您提供结果,现在如果您添加了列表,它将在可视化中显示列表的所有元素。您最多可以手动排除您不想在可视化中看到的术语。这是相同的链接。 elastic.co/guide/en/elasticsearch/reference/current/…
    猜你喜欢
    • 2021-07-09
    • 2023-03-25
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多