} else {
throw new SearchParseException(context, "Unexpected token " + token + " in [" + aggregationName + "].");
}
}
ScriptParameterValue initScriptValue = scriptParameterParser.getScriptParameterValue(INIT_SCRIPT);
String initScript = null;
ScriptType initScriptType = null;
if (initScriptValue != null) {
initScript = initScriptValue.script();
initScriptType = initScriptValue.scriptType();
}
ScriptParameterValue mapScriptValue = scriptParameterParser.getScriptParameterValue(MAP_SCRIPT);
String mapScript = null;
ScriptType mapScriptType = null;
if (mapScriptValue != null) {
mapScript = mapScriptValue.script();
mapScriptType = mapScriptValue.scriptType();
}
ScriptParameterValue combineScriptValue = scriptParameterParser.getScriptParameterValue(COMBINE_SCRIPT);
String combineScript = null;
ScriptType combineScriptType = null;
if (combineScriptValue != null) {
combineScript = combineScriptValue.script();
combineScriptType = combineScriptValue.scriptType();
}
ScriptParameterValue reduceScriptValue = scriptParameterParser.getScriptParameterValue(REDUCE_SCRIPT);
String reduceScript = null;
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 + "].");