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]
The index mapping are in: https://github.com/datacite/shiba-inu/blob/2d632d341a22a8dca2afec3b01c3b34030144c9c/templates/aggregating_es.json
Why is it returning an empty bucket?