# How to do aggregation in Elastic search with a field which has both keyword and text types

**URL:** https://discuss.elastic.co/t/how-to-do-aggregation-in-elastic-search-with-a-field-which-has-both-keyword-and-text-types/173083
**Category:** Elasticsearch
**Created:** [March 20, 2019, 6:47am UTC](https://discuss.elastic.co/t/how-to-do-aggregation-in-elastic-search-with-a-field-which-has-both-keyword-and-text-types/173083 "2019-03-20T06:47:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Sreejith\_Ms](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sreejith_ms/32/42392_2.png) [@Sreejith\_Ms](https://discuss.elastic.co/u/Sreejith_Ms)
#### Post date: [March 20, 2019, 6:47am UTC](https://discuss.elastic.co/t/how-to-do-aggregation-in-elastic-search-with-a-field-which-has-both-keyword-and-text-types/173083/1 "2019-03-20T06:47:38Z")

</div>

Im new to ES, Please help me to do the aggregation in Elastic search with a field which has both keyword and text types.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [March 20, 2019, 6:51am UTC](https://discuss.elastic.co/t/how-to-do-aggregation-in-elastic-search-with-a-field-which-has-both-keyword-and-text-types/173083/2 "2019-03-20T06:51:23Z")

</div>

A single field can not have multiple types. If you are referring to the default mapping that uses multifields, there are two separate fields that can be queried and aggregated on - `<field>` and `<field>.keyword`. Pick the one that has the mapping you need for your serach or aggregation.

---

<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: [April 17, 2019, 6:51am UTC](https://discuss.elastic.co/t/how-to-do-aggregation-in-elastic-search-with-a-field-which-has-both-keyword-and-text-types/173083/3 "2019-04-17T06:51:24Z")

</div>

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