# Why elasticsearch still check the length of a keyword field, even if it's not indexed?

**URL:** https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604
**Category:** Elasticsearch
**Created:** [June 5, 2018, 11:40am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604 "2018-06-05T11:40:51Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![esnewbie](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@esnewbie](https://discuss.elastic.co/u/esnewbie)
#### Post date: [June 5, 2018, 11:40am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/1 "2018-06-05T11:40:52Z")

</div>

Hi all,  
I'm new to Elasticsearch, using version 5.3.

As i understand, the length of `keyword` field is limited to about 32K due to the limitation of Lucene's term byte-length limit of 32766.

But, the thing I don't understand is, when I set a field type to `keyword`, and `index` to `false`，and `store` by default is `false`, means that this field is not indexed and not stored.  
When I save data that more than 32k into that field, I still get the error, says"DocValuesField "newField7" is too large, must be \<= 32766".

As my question, why elasticsarch still check the length of this filed, even if I don't index nor store it?  
Why not ignore it and just keep it in \_source? Is there any other things that elasticearch still have to do with this field, even if it's not indexed nor stored?

I think elasticsearch do not need to store this field's data to a Lucene term, right? then why keep the limitation?

---

<div class="post-metadata">

### Author: ![esnewbie](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@esnewbie](https://discuss.elastic.co/u/esnewbie)
#### Post date: [June 6, 2018, 5:58am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/2 "2018-06-06T05:58:08Z")

</div>

Can anyone help? @elastic

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 6, 2018, 6:33am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/3 "2018-06-06T06:33:07Z")

</div>

Read [this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and specifically the "Also be patient" part.

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 6, 2018, 6:34am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/4 "2018-06-06T06:34:47Z")

</div>

Have a look at [https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html)

---

<div class="post-metadata">

### Author: ![esnewbie](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@esnewbie](https://discuss.elastic.co/u/esnewbie)
#### Post date: [June 6, 2018, 7:16am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/5 "2018-06-06T07:16:38Z")

</div>

@dadoonet thanks for your response, and sorry for my rush reply. I will follow the code of conduct more carefully.

Back to my question.  
I have already found and read the link you provided before I post, and it just not answered my question.  
As the link page says:

> The `enabled` setting, which can be applied **only** to the mapping type and to object fields, causes Elasticsearch to skip parsing of the contents of the field entirely.The JSON can still be retrieved from the `_source` field, but it is not searchable or stored in any other way.

Which not solve my problem with`keyword` type field.  
In fact, what I expected is when I set a `keyword` type field to `"index": false, "store: false"`, Elasticsearch should treat it just like it does to a `"enabled: false" ` `object` field, which means just save it to `_source` without checking if the length is too large, because Elasticsearch no longer need to store this field to a Lucene term.

Is there any reason that Elasticsearch still have to check the length of `"index": false, "store: false"` `keyword` field?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 6, 2018, 7:30am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/6 "2018-06-06T07:30:46Z")

</div>

The goal of `keyword` data type is to be able to generate aggs on it or do sorting.  
In a sense, `keyword` is usable. That's why the length is checked IMO.

---

<div class="post-metadata">

### Author: ![esnewbie](https://avatars.discourse-cdn.com/v4/letter/e/9f8e36/32.png) [@esnewbie](https://discuss.elastic.co/u/esnewbie)
#### Post date: [June 6, 2018, 7:45am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/7 "2018-06-06T07:45:44Z")

</div>

OK, everybody sees different. I still expect the length should not be checked in this scenario.  
Maybe I should just use `object` type field in my situation instead of `keyword`.  
Thanks for your answer !

---

<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: [July 4, 2018, 7:45am UTC](https://discuss.elastic.co/t/why-elasticsearch-still-check-the-length-of-a-keyword-field-even-if-its-not-indexed/134604/8 "2018-07-04T07:45:46Z")

</div>

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