# My field is doc\_value , but got error : Fielddata is disabled on text fields by default. Set fielddata=true

**URL:** <https://discuss.elastic.co/t/my-field-is-doc-value-but-got-error-fielddata-is-disabled-on-text-fields-by-default-set-fielddata-true/66187>\
**Category:** Elasticsearch\
**Created:** [November 16, 2016, 2:49am UTC](https://discuss.elastic.co/t/my-field-is-doc-value-but-got-error-fielddata-is-disabled-on-text-fields-by-default-set-fielddata-true/66187 "2016-11-16T02:49:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![small-tomorrow](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/small-tomorrow/32/13319_2.png) [@small-tomorrow](https://discuss.elastic.co/u/small-tomorrow)\
**Post date:** [November 16, 2016, 2:49am UTC](https://discuss.elastic.co/t/my-field-is-doc-value-but-got-error-fielddata-is-disabled-on-text-fields-by-default-set-fielddata-true/66187/1 "2016-11-16T02:49:56Z")

</div>

I got ' Fielddata is disabled on text fields by default. Set fielddata=true' in my request , but it confused me ,since I put not\_analyzed to my field , so it is not a text field , which will support doc\_values according to [https://www.elastic.co/guide/en/elasticsearch/reference/5.0/fielddata.html#\_fielddata\_is\_disabled\_on\_literal\_text\_literal\_fields\_by\_default](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/fielddata.html#_fielddata_is_disabled_on_literal_text_literal_fields_by_default).  
**here is part of my template :**  
"timestamp": {  
"format": "epoch\_millis",  
"type": "date",  
"doc\_values": true  
},  
"device\_id": {  
"index": "not\_analyzed",  
"type": "string",  
"doc\_values": true  
},  
"name\_type": {  
"type": "integer",  
"doc\_values": true  
}

**when I try to request with a aggregtion like :**  
"aggs": {  
"cardinality\_count": {  
"cardinality": {  
"field": "device\_id"  
}  
}  
}  
**but I got failures as :**  
"reason": {  
"type": "illegal\_argument\_exception",  
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [device\_id] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."  
}  
**Any help will be great appreciated !**

---

<div class="post-metadata">

**Author:** ![small-tomorrow](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/small-tomorrow/32/13319_2.png) [@small-tomorrow](https://discuss.elastic.co/u/small-tomorrow)\
**Post date:** [November 16, 2016, 4:02am UTC](https://discuss.elastic.co/t/my-field-is-doc-value-but-got-error-fielddata-is-disabled-on-text-fields-by-default-set-fielddata-true/66187/3 "2016-11-16T04:02:50Z")

</div>

anyway, when I set my mapping before post data to it , the queries work ! but I have so much data generated with ES2.1.0 , so how can I make it ?

---

<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:** [December 14, 2016, 4:02am UTC](https://discuss.elastic.co/t/my-field-is-doc-value-but-got-error-fielddata-is-disabled-on-text-fields-by-default-set-fielddata-true/66187/4 "2016-12-14T04:02:55Z")

</div>

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