Help Center> Document Database Service> FAQs> Database Usage> How Do I Use MapReduce Commands?
Updated on 2023-01-18 GMT+08:00

How Do I Use MapReduce Commands?

Overview

MapReduce commands are used for executing map-reduce operations on big data.

How Do I Enable MapReduce Commands?

The MapReduce command is controlled by the DDS parameter security.javascriptEnabled. The default value is false, indicating that the mapReduce and group commands are unavailable. If you need to use the MapReduce command, change the parameter value to true. Then, restart the DB instance for the change to take effect.

  • For a cluster instance, change the parameter values in the parameter template associated with all shard nodes and restart the instance for the change to take effect.
  • For a replica set or single-node instance, change the parameter values in the parameter template associated with the instance and restart the instance for the change to take effect.

For details about how to change parameter values, see Editing a Parameter Template.

Common Errors and Handling Methods for MapReduce Command Execution Failures

Error information: cannot run map reduce without the js engine or map is not defined

Figure 1 Case 1
Figure 2 Case 2

Possible cause: MapReduce commands are restricted and cannot be used.

Solution: Change the value of security.javascriptEnabled in the instance parameter template to true and restart the instance for the change to take effect.

If a parameter template is a default parameter template, you are not allowed to change its parameter values. You can create a parameter template and change the corresponding parameter values. After the change, associate the new parameter template with the instance. For details, see Changing the Associated Parameter Template.

Database Usage FAQs

more