# Long keyword/text fields just for retrieval

**URL:** https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374
**Category:** Elasticsearch
**Created:** [January 12, 2017, 1:00pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374 "2017-01-12T13:00:40Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kuba](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kuba](https://discuss.elastic.co/u/kuba)
#### Post date: [January 12, 2017, 1:00pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374/1 "2017-01-12T13:00:40Z")

</div>

Hi,

I need to store long fields, which I won't use for searching, sorting or aggregation. Which type should I use?

Keyword makes me think of short values like 'id', 'login', 'type'...

But I don't need to analyze/tokenize the field, I just want to put it in the elasticsearch and get it back.

Should I use `keyword`... maybe with some options like `"doc_values": false`?

Or `text` with `"index": false`?

Which would be more performant or anyhow more proper?

---

<div class="post-metadata">

### Author: ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)
#### Post date: [January 12, 2017, 1:42pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374/2 "2017-01-12T13:42:14Z")

</div>

For this I would use a `keyword` field with `"index": false` and `"doc_values": false`

---

<div class="post-metadata">

### Author: ![kuba](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kuba](https://discuss.elastic.co/u/kuba)
#### Post date: [January 12, 2017, 3:28pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374/3 "2017-01-12T15:28:14Z")

</div>

There is a problem with field length..

`Document contains at least one immense term in field=\\\"value\\\" (whose UTF8 encoding is longer than the max length 32766), all of which were skipped`  
(...)  
`bytes can be at most 32766 in length`

---

<div class="post-metadata">

### Author: ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)
#### Post date: [January 12, 2017, 3:32pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374/4 "2017-01-12T15:32:08Z")

</div>

This suggest that the `"index":false` setting was not applied. Can you check the mapping for that field and ensure that both `"index":false` and `"doc_values: false` are applied (you can do this by doing `GET <INDEX_NAME>/_mapping`) ?

---

<div class="post-metadata">

### Author: ![kuba](https://avatars.discourse-cdn.com/v4/letter/k/a587f6/32.png) [@kuba](https://discuss.elastic.co/u/kuba)
#### Post date: [January 12, 2017, 3:41pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374/5 "2017-01-12T15:41:19Z")

</div>

Thank you for quick answer. Turns out my script didn't add `"index": false` to the mapping.

Big thanks again!

---

<div class="post-metadata">

### Author: ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)
#### Post date: [January 12, 2017, 3:41pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374/6 "2017-01-12T15:41:47Z")

</div>

No Problem, glad you got it working 🙂

---

<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: [February 9, 2017, 3:42pm UTC](https://discuss.elastic.co/t/long-keyword-text-fields-just-for-retrieval/71374/7 "2017-02-09T15:42:28Z")

</div>

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