# Painless lowercase of a keyword field

**URL:** <https://discuss.elastic.co/t/painless-lowercase-of-a-keyword-field/132470>\
**Category:** Elasticsearch\
**Created:** [May 18, 2018, 10:53am UTC](https://discuss.elastic.co/t/painless-lowercase-of-a-keyword-field/132470 "2018-05-18T10:53:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SKumarMN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skumarmn/32/27537_2.png) [@SKumarMN](https://discuss.elastic.co/u/SKumarMN)\
**Post date:** [May 18, 2018, 10:53am UTC](https://discuss.elastic.co/t/painless-lowercase-of-a-keyword-field/132470/1 "2018-05-18T10:53:50Z")

</div>

Hi All,

I have a index with a field which is of type keyword. The data is stored in upper case. I want to use \_update\_by\_query and convert it to lowercase using Painless. Could you please help.

sample document  
{  
"field1":"TEST"  
}

Output needed after update:  
{  
"field1":"test"  
}

---

<div class="post-metadata">

**Author:** ![SKumarMN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skumarmn/32/27537_2.png) [@SKumarMN](https://discuss.elastic.co/u/SKumarMN)\
**Post date:** [May 18, 2018, 11:01am UTC](https://discuss.elastic.co/t/painless-lowercase-of-a-keyword-field/132470/2 "2018-05-18T11:01:23Z")

</div>

Hi,

I could find the solution myself. posting it for benefit of others

{

"script":  
{  
"inline": "ctx.\_source. field1 = ctx.\_source.field1.toLowerCase()"  
}  
}

---

<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:** [June 15, 2018, 11:16am UTC](https://discuss.elastic.co/t/painless-lowercase-of-a-keyword-field/132470/3 "2018-06-15T11:16:18Z")

</div>

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