# Mapping: Array Type vs Text Type(with fielddata set to true)

**URL:** https://discuss.elastic.co/t/mapping-array-type-vs-text-type-with-fielddata-set-to-true/73759
**Category:** Elasticsearch
**Created:** [February 2, 2017, 8:58pm UTC](https://discuss.elastic.co/t/mapping-array-type-vs-text-type-with-fielddata-set-to-true/73759 "2017-02-02T20:58:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![avr](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@avr](https://discuss.elastic.co/u/avr)
#### Post date: [February 2, 2017, 8:58pm UTC](https://discuss.elastic.co/t/mapping-array-type-vs-text-type-with-fielddata-set-to-true/73759/1 "2017-02-02T20:58:07Z")

</div>

I've a use case where I want to use **text** field in aggregations. By default _text_ fields are not aggregatable and to make them aggregatable we need to enable **fielddata** parameter in the mapping.  
As enabling _fielddata_ comes with cost of HEAP, I'm wondering if following workaround makes any sense!

1. Pre-Analyse( tokenize text field) and make array out of it and index it as **Array Type**
2. After indexing text field as array type(into field called "_text\_array_") I'll get two fields one is **text\_array** (Text Type) and another one is **text\_array.keyword** (Keyword Type)
3. As **text\_array.keyword** is type _Keyword_ I can use this in aggregations.

Is creating **text\_array.keyword** makes sense? or does it also consumes HEAP when it is used in aggregations?

Any help on this much appreciated!

---

<div class="post-metadata">

### Author: ![mnozawa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mnozawa/32/15091_2.png) [@mnozawa](https://discuss.elastic.co/u/mnozawa)
#### Post date: [February 3, 2017, 12:49am UTC](https://discuss.elastic.co/t/mapping-array-type-vs-text-type-with-fielddata-set-to-true/73759/2 "2017-02-03T00:49:10Z")

</div>

Hi,

By default, the **doc\_values** setting is **true** In keyword datatype field .  
So it doesn't consume so many heap at aggregation.

> **[Keyword type family | Elasticsearch Guide \[master\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/master/keyword.html)**

> [@avr](#):
>
> one is text\_array (Text Type)

On the other hand, text type field may not necessary (it depends on your use case)

---

<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: [March 3, 2017, 12:49am UTC](https://discuss.elastic.co/t/mapping-array-type-vs-text-type-with-fielddata-set-to-true/73759/3 "2017-03-03T00:49:17Z")

</div>

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