# Elasticsearch 6.2 - Composite Bucket Aggregation with Sum Bucket Aggregation and Pipeline Aggregations

**URL:** https://discuss.elastic.co/t/elasticsearch-6-2-composite-bucket-aggregation-with-sum-bucket-aggregation-and-pipeline-aggregations/142658
**Category:** Elasticsearch
**Created:** [August 1, 2018, 11:35pm UTC](https://discuss.elastic.co/t/elasticsearch-6-2-composite-bucket-aggregation-with-sum-bucket-aggregation-and-pipeline-aggregations/142658 "2018-08-01T23:35:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![BrobaFett](https://avatars.discourse-cdn.com/v4/letter/b/ecccb3/32.png) [@BrobaFett](https://discuss.elastic.co/u/BrobaFett)
#### Post date: [August 1, 2018, 11:35pm UTC](https://discuss.elastic.co/t/elasticsearch-6-2-composite-bucket-aggregation-with-sum-bucket-aggregation-and-pipeline-aggregations/142658/1 "2018-08-01T23:35:01Z")

</div>

Hi,

I wanted to confirm if this feature is unavailable as of 6.2.

Currently, I am able to create buckets according to my sources using the Composite Bucket Aggregation. I then run several sub-aggregations (Sum Metric Aggregations) on each bucket for certain fields.

I also want to sum the values from all the sub-aggregation's sums together into some overarching sum values.

I thought using a Pipeline Aggregation would the best approach for this.

Running the query yields the following error:  
"The first aggregation in buckets\_path must be a multi-bucket aggregation for aggregation"

I switched from Composite Aggregation to a Terms Aggregation to confirm my Pipeline Aggregation syntax was correct.

Is Composite Aggregation not considered a multi-bucket aggregation in 6.2?

Thank you.

---

<div class="post-metadata">

### Author: ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)
#### Post date: [August 2, 2018, 12:02am UTC](https://discuss.elastic.co/t/elasticsearch-6-2-composite-bucket-aggregation-with-sum-bucket-aggregation-and-pipeline-aggregations/142658/2 "2018-08-02T00:02:27Z")

</div>

We have a special way to mark aggregations that are eligible for pipeline metrics aggregation but the `composite` aggregation does not implement this marker. The `composite` agg is indeed a multi bucket aggregation so this should be considered as a bug. Can you open an issue in github with a simple recreation ?

---

<div class="post-metadata">

### Author: ![BrobaFett](https://avatars.discourse-cdn.com/v4/letter/b/ecccb3/32.png) [@BrobaFett](https://discuss.elastic.co/u/BrobaFett)
#### Post date: [August 2, 2018, 4:56pm UTC](https://discuss.elastic.co/t/elasticsearch-6-2-composite-bucket-aggregation-with-sum-bucket-aggregation-and-pipeline-aggregations/142658/3 "2018-08-02T16:56:27Z")

</div>

Sure, can do.

This is also a simplified recreation of the issue....

My template mapping...

```auto
PUT _template/template_default
{
    "mappings": {
      "_doc": {
        "_all": {
				  "enabled": false
			  },
  			"dynamic": "strict",
  			"properties": {
  				"itemId": {
  				   "type": "keyword",
  				   "norms": false
  				},
  				"inputQty": {
  				   "type": "integer",
  				   "index": false
  				},
  				"orderQty": {
  				   "type": "integer",
  				   "index": false
  				},
  				"centerId": {
  					"type": "keyword",
  					"eager_global_ordinals": true,
  					"norms": false
  				},
  				"submittedQty": {
  					"type": "integer",
  					"index": false
  				},
  				"confirmedQty": {
  					"type": "integer",
  					"index": false
  				}
        }
      }
    }
}

```

My REST call

```auto
POST items-0*/_search?ignore_unavailable=true
{
    "size": 0,
    "track_total_hits": false,
    "aggs" : {
      "myBuckets" : {
        "composite" : {
          "size" : 100000,
          "sources" : [
              { "center_name" : { "terms" : { "field" : "centerId"} } }
            ]
          },
          "aggs" : {
            "requested_units" : { "sum": { "field" : "inputQty" } },
            "approved_units" : { "sum": { "field" : "orderQty" } },
            "submitted_quantity" : { "sum" : { "field" : "submittedQty"} },
            "confirmed_quantity" : { "sum" : { "field" : "confirmedQty"} }
          }
      },
      "check_pipeline_agg": {
        "sum_bucket": {
          "buckets_path": "fc_buckets>requested_units"
        }
      }
    }
}

```

Thanks. I'll link the issue as well when I open it

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 30, 2018, 4:56pm UTC](https://discuss.elastic.co/t/elasticsearch-6-2-composite-bucket-aggregation-with-sum-bucket-aggregation-and-pipeline-aggregations/142658/4 "2018-08-30T16:56:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
