Databases Reference
In-Depth Information
ignores this scope. It has its own scope key, "scope" , and you must use that if there are
client-side values you want to use in your MapReduce. You can set them using a plain
document of the form variable_name : value , and they will be available in your map ,
reduce , and finalize functions. The scope is immutable from within these functions.
For instance, in the example in the previous section, we calculated the recency of a page
using 1/(new Date() - this.date) . We could, instead, pass in the current date as part
of the scope with the following code:
> db.runCommand({"mapreduce" : "webpages", "map" : map, "reduce" : reduce,
"scope" : {now : new Date()}})
Then, in the map function, we could say 1/(now - this.date) .
Getting more output
There is also a verbose option for debugging. If you would like to see the progress of
your MapReduce as it runs, you can specify "verbose" : true .
You can also use print to see what's happening in the map , reduce , and finalize func-
tions. print will print to the server log.
 
Search WWH ::




Custom Search