Doing this during query time will be pretty slow. If you keep running this query, doing this on index time sounds way better to me. You could use an ingest processor to do this, see this example
PUT _ingest/pipeline/count_length
{
"processors": [
{
"script": {
"source": "ctx.keyword_length = ctx.make.length();"
}
}
]
}
PUT foo/_doc/1?pipeline=count_length
{
"make" : "this are a few chars"
}
GET foo/_doc/1
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.