Deprecated: Optional parameter $keys declared before required parameter $cms_id is implicitly treated as a required parameter in /home/www/dev/work/class/blog/CmsKey.php on line 75

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$outlink is deprecated in /home/www/dev/work/website/lvesu/template/blog/cms/cms.tpl on line 2

Deprecated: Creation of dynamic property lvesu\lvesu\controller\blog\main::$status is deprecated in /home/www/dev/work/website/lvesu/template/blog/index.head.php on line 2
elasticsearch集群nested嵌套统计 - 互联网笔记

略微加速

略速 - 互联网笔记

elasticsearch集群nested嵌套统计

2020-12-21 leiting (4603阅读)

标签 Elasticsearch

{
  "size": 0,
  "aggs": {
    "my_id": {
      "terms": {
        "field": "id",//嵌套父级的字段
        "size": 1000
      },
      "aggs": {
        "my_date": {
          "nested": {//嵌套结构
            "path": "all_dates"
          },
          "aggs": {
            "my_price": {
              "avg": {//求每个ID下嵌套结构里价格的平均值
                "field": "all_dates.price"
              }
            }
          }
        }
      }
    }
  }
}


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3