I would like to do an aggregation on a nested field, and I would like to include empty occurrences too.
What I tried:
GET index/_search
{
"size": 0,
"aggs": {
"language_skills": {
"nested": {
"path": "language_skills"
},
"aggs": {
"result": {
"terms": {
"field": "language_skills.language",
"missing": "N/A"
}
}
}
}
}
}
what I get:
"aggregations" : {
"language_skills" : {
"doc_count" : 157,
"result" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "de",
"doc_count" : 73
},
{
"key" : "en",
"doc_count" : 62
},
{
"key" : "fr",
"doc_count" : 19
},
{
"key" : "it",
"doc_count" : 3
}
]
}
}
}
What I expect:
"aggregations": {
"language_skills": {
"doc_count": 157,
"result": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "de",
"doc_count": 73
},
{
"key": "en",
"doc_count": 62
},
{
"key": "fr",
"doc_count": 19
},
{
"key": "it",
"doc_count": 3
},
{
"key": "N/A", <---- this bucket is missing
"doc_count": 21
}
]
}
}
}
Tried some other queries as well, with no luck.
Any help would be highly appreciated.