Painless lowercase of a keyword field

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"
}

Hi,

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

{

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