在 Vega + Kibana 中查看任何不是 `doc_count` 的内容

View anything in Vega + Kibana that is not a `doc_count`

我目前正在 Kibana 中开发 Vega 可视化。下图显示了 doc_count 个索引,这实际上是 Kibana 在 Amazon ELK 中提供的默认脚本。虽然在 https://vega.github.io/editor 中开发更简单,但最终的想法是在仪表板中可视化 Elasticsearch 数据。

有一些将 Vega 与 Kibana 集成的示例,但最后我只找到了显示索引 doc_count 的示例。例如,https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana

目前,我正在查看 https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-search.html 以获取有关自定义搜索查询的详细信息,以便 return 聚合存储桶中 doc_count 以外的内容。

所以我在 https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-aggregations-bucket-filter-aggregation.html 中发现只需要在桶聚合中添加一个 sub-aggregation 或另一个聚合就可以在桶中得到一个不同于 doc_count 的值。

以此为例:

POST /sales/_search?size=0
{
    "aggs" : {
        "sales_over_time" : {
            "date_histogram" : {
                "field" : "date",
                "calendar_interval" : "month"
            },
            "aggs" : {
                "avg_price" : { "avg" : { "field" : "price" } }
            }
        }
    }
}