# DSL Aggregations: How to get results, even if one of the aggs field is not present?

**URL:** <https://discuss.elastic.co/t/dsl-aggregations-how-to-get-results-even-if-one-of-the-aggs-field-is-not-present/255360>\
**Category:** Elasticsearch\
**Created:** [November 13, 2020, 3:07pm UTC](https://discuss.elastic.co/t/dsl-aggregations-how-to-get-results-even-if-one-of-the-aggs-field-is-not-present/255360 "2020-11-13T15:07:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelk](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kelk](https://discuss.elastic.co/u/kelk)\
**Post date:** [November 13, 2020, 3:07pm UTC](https://discuss.elastic.co/t/dsl-aggregations-how-to-get-results-even-if-one-of-the-aggs-field-is-not-present/255360/1 "2020-11-13T15:07:50Z")

</div>

We have to do aggregations for  
host.os.name, host.name, host.ip

99% data has host.os.name  
95% has host.name  
25% has host.ip

How to ensure I get all the results, even if the field is not present?

So i'm looking for a table like

```auto
| host.os |host.name | host.ip | count|
|---|---|---|--|
|linux | mylinuxhost1 | 172.2.3.4|20|
|linux | mylinuxhost2 | NULL|10|
| windows | winhost1 | 12.2.3.4 |100|
| windows | winhost1 | NULL |5|

```

I was just doing like below, the output gives me ONLY if all the fields are present

```auto
           "aggs": {
             ....
                "group_by_name": {
                    "terms": {
                        "field": "host.name.keyword"
                    },
                    "aggs": {
                      "group_by_ip": {
                          "terms": {
                              "field": "host.ip.keyword"
                          }, ....

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 17, 2020, 11:17pm UTC](https://discuss.elastic.co/t/dsl-aggregations-how-to-get-results-even-if-one-of-the-aggs-field-is-not-present/255360/2 "2020-11-17T23:17:15Z")

</div>

Have you seen [https://www.elastic.co/guide/en/elasticsearch/reference/7.10/search-aggregations-bucket-terms-aggregation.html#\_missing\_value\_5](https://www.elastic.co/guide/en/elasticsearch/reference/7.10/search-aggregations-bucket-terms-aggregation.html#_missing_value_5), it might help?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 15, 2020, 11:17pm UTC](https://discuss.elastic.co/t/dsl-aggregations-how-to-get-results-even-if-one-of-the-aggs-field-is-not-present/255360/3 "2020-12-15T23:17:17Z")

</div>

Closed on December 15, 2020, 11:17pm UTC

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