# Keyword subfield of a text field which has high cardinality

**URL:** https://discuss.elastic.co/t/keyword-subfield-of-a-text-field-which-has-high-cardinality/231599
**Category:** Elasticsearch
**Created:** [May 7, 2020, 5:42pm UTC](https://discuss.elastic.co/t/keyword-subfield-of-a-text-field-which-has-high-cardinality/231599 "2020-05-07T17:42:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lloadingll](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lloadingll](https://discuss.elastic.co/u/lloadingll)
#### Post date: [May 7, 2020, 5:42pm UTC](https://discuss.elastic.co/t/keyword-subfield-of-a-text-field-which-has-high-cardinality/231599/1 "2020-05-07T17:42:41Z")

</div>

Hi all,  
we have a large amount of data, one of its fields is 'email subject' which is 'text' type. Recently I want to do aggregation by this field on a small subset of the data  
(assume after the query filter there are 100K hits to aggregate).  
so I plan to modify the field to something like:

```auto
   "Subject": {
                    "type": "text",
                    "fields": {
                        "Raw": {
                            "type": "keyword"
                        }
                    }
                }

```

And then aggregate by Subject.Raw  
I know it's ok for normal fields. But as email titles can be pretty long and have a large cardinality, I'm worried about whether using 'keyword' there will cause some kind of memory overflow, etc.  
I guess when querying, 100K hits may not be a problem as it's pretty small. But is there any risk when Elasticsearch do things like building index on this long and high-cardinality 'keyword' field and the total amount is huge?

Maybe I can use 'ignore\_above' to limit the keyword length... then how about the cardinality?

Thanks a lot!

---

<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: [June 4, 2020, 5:42pm UTC](https://discuss.elastic.co/t/keyword-subfield-of-a-text-field-which-has-high-cardinality/231599/2 "2020-06-04T17:42:47Z")

</div>

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