How to find the length of a field

I have an index with a field DataAscii of type string. I would like to plot the length of this field in timeline. One option is to use scripted field. I have tried with following, but it does seems to be working

doc['DataAscii'].value.length()

In fact, a very simple expression like doc['DataAscii'].value is giving me the error

Courier fetch: 5 out of 10 shards failed

Check your Elasticsearch logs to see what is causing this.