curl --user elastic:passwds -XPOST ‘1.1.1.1:9200/indexname/_search?pretty’ -H “Content-Type: application/json” -d ‘{ “size”:0, “aggregations”: { “cpu_max”: { “max”: { “script”: "def myString = doc[’"‘cpu_info.total_used_pre.keyword’"’].value;def beginIndex = myString.lastIndexOf(’"’%’"’);def subString = myString.substring(0,beginIndex);return Double.parseDouble(subString); "}}}}’
涉及点:nest类型在脚本中的取值。字符串截取。字符串强转double