# Painless - access non-analyzed version of analyzed text field

**URL:** https://discuss.elastic.co/t/painless-access-non-analyzed-version-of-analyzed-text-field/183863
**Category:** Elasticsearch
**Created:** [June 2, 2019, 2:47pm UTC](https://discuss.elastic.co/t/painless-access-non-analyzed-version-of-analyzed-text-field/183863 "2019-06-02T14:47:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Eran\_H](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eran_h/32/46227_2.png) [@Eran\_H](https://discuss.elastic.co/u/Eran_H)
#### Post date: [June 2, 2019, 2:47pm UTC](https://discuss.elastic.co/t/painless-access-non-analyzed-version-of-analyzed-text-field/183863/1 "2019-06-02T14:47:07Z")

</div>

For every analyzed text field, ES creates by default a non-analyzed version for a text field under the name `keyword`.

We should be able to use it, however `doc["text_field.keyword"].value` doesn't work in painless.  
It throws the error "index\_out\_of\_bounds\_exception".  
For fields that don't exist I get a different error - "No field found for [text\_field.keyword2] in mapping with types ", so it seems it should work.

Does this make sense? If yes, is there a workaround?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 3, 2019, 12:33pm UTC](https://discuss.elastic.co/t/painless-access-non-analyzed-version-of-analyzed-text-field/183863/2 "2019-06-03T12:33:14Z")

</div>

can you come up with a reproducible example please? including a sample document and the query that contains a script you are executing? Thanks!

---

<div class="post-metadata">

### Author: ![Eran\_H](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eran_h/32/46227_2.png) [@Eran\_H](https://discuss.elastic.co/u/Eran_H)
#### Post date: [June 5, 2019, 3:29pm UTC](https://discuss.elastic.co/t/painless-access-non-analyzed-version-of-analyzed-text-field/183863/3 "2019-06-05T15:29:53Z")

</div>

I wrote an example to reproduce it but it worked, I can't seem to reproduce it.  
Apparently painless supports this and something is wrong with my index, will update if I manage to understand how to reproduce it.  
Thanks!

---

<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 3, 2019, 3:30pm UTC](https://discuss.elastic.co/t/painless-access-non-analyzed-version-of-analyzed-text-field/183863/4 "2019-07-03T15:30:14Z")

</div>

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