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

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