ScriptType reduceScriptType = null;
if (reduceScriptValue != null) {
reduceScript = reduceScriptValue.script();
reduceScriptType = reduceScriptValue.scriptType();
}
scriptLang = scriptParameterParser.lang();
if (mapScript == null) {
throw new SearchParseException(context, "map_script field is required in [" + aggregationName + "].");
}
return new ScriptedMetricAggregator.Factory(aggregationName, scriptLang, initScriptType, initScript, mapScriptType, mapScript,