Empty bucket while aggregating on nested documents

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 ?

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

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