What is the correct and better way to get scripted fields in elastic query


I am using below script for getting scripted fields and also in aggregation. and it works fine, but I was wondering if there is some other better way of doing this.

"script_fields": {
"CustomColumn1": {
"script": " (( ((params._source['productDescription'].toLowerCase().indexOf('chain') > -1)) )) ? ('ChainQuantity') : (( ((params._source['productDescription'].toLowerCase().indexOf('ribbon') > -1)) )) ? ('Ribbon_QTY') : 'blank'"

Please suggest

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