How to use multiple Composite Aggregations in ElasticSearch?

I am trying to obtain two composite aggregations in ElasticSearch but the second one is always giving me an empty bucket.

GET /resolutions/_search

{
	"query": {
		"query_string": {
			"query": "*"
		}
	},
	"aggs": {
		"total": {
			"composite": {
				"sources": [
					{"doi": {"terms": {"field": "doi"}}},
					{"access_method": {"terms": {"field": "access_method"}}}
				],
				"size": 10000
			}
		},
		"unqiue": {
			"composite": {
				"sources": [
					{"doi": {"terms": {"field": "doi"}}},
					{"access_method": {"terms": {"field": "access_method"}}},
					{"session": {"terms": {"field": "session"}}}
				],
				"size": 10000
			}
		}
	},
	"size": 0,
	"track_total_hits": false
}

In the response, you can see the first aggregation (total) with 1000s of objects in the bucket but the second one aggreagtion (unique) is always empty. I have tried swaping the order of the aggregations and it's always the second one in order that is empty.

[![Reponse with second bucket empty][2]][2]

enter image description here

The index mapping are in: https://github.com/datacite/shiba-inu/blob/2d632d341a22a8dca2afec3b01c3b34030144c9c/templates/aggregating_es.json

Why is it returning an empty bucket?

Why is it returning an empty bucket?

This is a bug :frowning:
The execution of the first composite aggregation breaks the second one. The fix is already committed and will be available soon (in 6.5.0).

1 Like

Thanks

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