# Composite aggregation behavior when missing a key, not value

**URL:** <https://discuss.elastic.co/t/composite-aggregation-behavior-when-missing-a-key-not-value/293407>\
**Category:** Elasticsearch\
**Created:** [January 4, 2022, 6:17am UTC](https://discuss.elastic.co/t/composite-aggregation-behavior-when-missing-a-key-not-value/293407 "2022-01-04T06:17:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lstoneir](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@lstoneir](https://discuss.elastic.co/u/lstoneir)\
**Post date:** [January 4, 2022, 6:17am UTC](https://discuss.elastic.co/t/composite-aggregation-behavior-when-missing-a-key-not-value/293407/1 "2022-01-04T06:17:01Z")

</div>

Hi every body!  
I'm using composite aggregation to multi terms on my data.  
some where in docs elastic says:

By default documents without a value for a given source are ignored. It is possible to include them in the response by setting `missing_bucket` to `true`

I have a question! what is the behavior of this aggregation when a key is missing?

for example my data is :

```auto
{
car: "toyota",
color: "white",
cost: 3
},
{
car: "toyota",
cost: 5
},
{
car: "benz",
color: "white",
cost: 6
},
{
"car": "honda"
}

```

what is the output of the above when i use:

```auto
{
            "size": 0, 
            "query": {
                "match_all": {
                }
            },
            "aggs": {
                "group_by": {
                "composite": {
                    "size": 65535, 
                    "sources": [
                    {
                        "car": {
                        "terms": {
                            "field": "car",
                            "missing_bucket": true
                        }
                        }
                    },
                    {
                        "color": {
                        "terms": {
                            "field": "color",
                            "missing_bucket": true
                        }
                        }
                    }
                    ]
                }},
                "aggs": {
                    "cost": {
                    "sum": {
                        "field": "cost"
                    }
                }
                }
            }
        }

```

---

<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:** [February 1, 2022, 6:17am UTC](https://discuss.elastic.co/t/composite-aggregation-behavior-when-missing-a-key-not-value/293407/2 "2022-02-01T06:17:35Z")

</div>

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