【问题标题】:Kibana dashboard - source data from 2 indices with the same mappingKibana 仪表板 - 来自具有相同映射的 2 个索引的源数据
【发布时间】:2015-07-16 09:48:27
【问题描述】:

我正在尝试设置 Kibana 仪表板。 在 Elasticsearch 中,只有一种类型的文档。
我们有两个具有相同映射的索引:

索引product_1 和product_2:

"_index": "product_1",
"_type": "product",
"_id": "3da33451d10f095c4b8cd485133dc23639244538",
"_score": 1,
"_source": {
    ...
    source": { "brand": "","category": "","store": "Store1"}
    ...
}

"_index": "product_1",
"_type": "product",
"_id": "3da33451d10f095c4b8cd485133dc23639244538",
"_score": 1,
"_source": {
    ...
    source": { "brand": "","category": "","store": "Store2"}
    ...
}
...

我们已经成功创建了关注可视化。
我们需要统计每个字段store的产品(文档)总数:

Top 0 source.store    Count
Store1                52,517
Store2                31,517
Store3                12,838
...

所以,问题是:我们如何在这里从第二个索引添加数据,以获得这样的结果:

Top 0 source.store    Count (product_1)    Count (product_2)
Store1                52,517               42,517
Store2                31,517               56,517
Store3                12,838               13,890
...

非常感谢。

PS:我们已经设法从 2 个索引中收集数据:
["product_1","product_2"]
所以kibana源数据,就好像它是一个索引一样,我们得到了错误的结果:

Top 0 source.store    Count (product_1+product_2)
Store1                102,517
Store2                62,517
Store3                24,838
...

【问题讨论】:

    标签: kibana querydsl kibana-4


    【解决方案1】:

    我不完全确定您所尝试的是否可行。来自the elastic search index documentation:

    The easiest and most familiar layout clones what you would expect from a relational database. 
    You can (very roughly) think of an index like a database.
    
    MySQL => Databases => Tables => Columns/Rows
    Elasticsearch => Indices => Types => Documents with Properties
    

    据我了解,您正在尝试在单个查询中从两个数据库(索引)中获取数据,据我所知,这是不可能的 - 至少按照您想要的方式,即根据结果分类到索引。

    现在您可能(应该)有一个问题,如果这完全不可能,您是如何得到以下结果的?

    Top 0 source.store    Count (product_1+product_2)
    Store1                102,517
    Store2                62,517
    Store3                24,838
    

    这就是 Kibana 的魅力所在。您可以使用通配符创建索引模式。这将查询卡内的每个索引。例如,创建 logstash-* 将查询所有 logstash-[date] 索引并给出您看到的综合结果。在您的情况下,可以通过将索引模式创建为 product_* 来实现。但我认为你不能得到索引明智的分类结果(我想这正是你正在寻找的)。

    【讨论】:

      猜你喜欢
      • 2015-02-18
      • 2014-05-06
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-15
      相关资源
      最近更新 更多