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

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.

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 ?

Sure, can do.

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

My template mapping...

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

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

3 Likes

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