Kibana Bargraph不能正确过滤数据。

问题描述 投票:0回答:1

我在索引 "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
            }
          }
        }
      }
    }
  }
}

当我在Kibana中创建一个条形图可视化时,选择X轴为 。

Aggregation : Terms
Filed : Tags.Tag.keyword

图形得到正确的建立。当我在Kibana中选择 标签 : 发展,我越来越 两条,一条过滤 "发展",另一条过滤 "电信" (如截图所示)enter image description here

我如何建立图形,以 当我对任何一个Tag进行过滤时,我应该只得到该Tag的数据。?

elasticsearch kibana elastic-stack elk kibana-7
1个回答
0
投票

这可能是由于你是 在Tags.Tag.Tag字段中存储字符串列表。 在本文档中。如果是这样,那么elasticsearch的功能就正常了。

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

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

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

所以后台的elasticsearch会启动一个查询,并尝试聚合所有文档中的术语,其中 "abc "出现在 "Tags.Tag.keyword "字段中。

所以在你的案例中,有术语development的文档,可能也有一个值telecom在里面,所以它向你显示这个。

© www.soinside.com 2019 - 2024. All rights reserved.