# Empty bucket while aggregating on nested documents

**URL:** <https://discuss.elastic.co/t/empty-bucket-while-aggregating-on-nested-documents/89898>\
**Category:** Elasticsearch\
**Created:** [June 19, 2017, 8:30am UTC](https://discuss.elastic.co/t/empty-bucket-while-aggregating-on-nested-documents/89898 "2017-06-19T08:30:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sravanthi\_N\_S\_CH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sravanthi_n_s_ch/32/50473_2.png) [@Sravanthi\_N\_S\_CH](https://discuss.elastic.co/u/Sravanthi_N_S_CH)\
**Post date:** [June 19, 2017, 8:30am UTC](https://discuss.elastic.co/t/empty-bucket-while-aggregating-on-nested-documents/89898/1 "2017-06-19T08:30:06Z")

</div>

Currently I have an index whose mappings are as below.

```
{
   "mappings": {
      "product": {
         "properties": {
         	"id": {
               "type": "text"
            },
            "displayName": {
               "type": "text"
            },
            "extraProperties": {
               "type": "nested",
               "properties": {
                  "id": {
                     "type":"text"
                  },
                  "colorName": { "type" : "text" },
                  "sizeKey": { "type" : "text" }
               }
            }
         }
      }
   }
}

```

If I have to aggregate on the sizeKey field, the aggregation query would like below

```
"aggs" : {
        "product" : {
            "nested" : {
                "path" : "extraProperties"
            },
            "aggs" : {
             "sized" : {
            "terms" : { "field" : "extraProperties.sizeKey.keyword" }
           }
          }
        }
    }

```

But the aggregation query right now gives empty bucket (as shown below).  
\> "aggregations": {

> ```
> "product": {
> "doc_count": 3,
> "sized": {
> "doc_count_error_upper_bound": 0,
> "sum_other_doc_count": 0,
> "buckets": []
> }
> }
> 
> ```

```
   }

```

**Can some one help me with this ? Is there something that am missing ?**

---

<div class="post-metadata">

**Author:** ![Sravanthi\_N\_S\_CH](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sravanthi_n_s_ch/32/50473_2.png) [@Sravanthi\_N\_S\_CH](https://discuss.elastic.co/u/Sravanthi_N_S_CH)\
**Post date:** [June 19, 2017, 10:19am UTC](https://discuss.elastic.co/t/empty-bucket-while-aggregating-on-nested-documents/89898/2 "2017-06-19T10:19:23Z")

</div>

When I change the type from **text** to **string** , I could see the results.

---

<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:** [July 17, 2017, 10:19am UTC](https://discuss.elastic.co/t/empty-bucket-while-aggregating-on-nested-documents/89898/3 "2017-07-17T10:19:28Z")

</div>

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