Call Map Reduce script from server script

Map/reduce scripts can be submitted for processing on an on-demand basis from another server-side script

Step 1) Create your map/reduce script entry point script. This process includes uploading a JavaScript file and creating a script record based on that file.

Step 2) In the server-side script where you want to submit the map/reduce script, call task.create(options) to return a task.MapReduceScriptTask object.

var scriptTask = task.create({taskType: task.TaskType.MAP_REDUCE});

Set the MapReduceScriptTask.scriptId and MapReduceScriptTask.deploymentId properties:

scriptTask.scriptId = ‘customscript1’;

scriptTask.deploymentId = ‘customdeploy1’;
Call MapReduceScriptTask.submit() to submit the script for processing.

scriptTask.submit();

Leave a comment

Your email address will not be published. Required fields are marked *