September 2017
Beginner to intermediate
412 pages
8h 55m
English
MongoDB implements the MapReduce framework with its mapReduce() command. An example is shown in Figure 11-6.

Figure 11-6. Running MapReduce in MongoDB
The first two statements define the JavaScript functions map1() and reduce1(). The third statement runs MapReduce on our library.books collection (see Chapter 10, NoSQL Databases), applying those two functions, and naming the resulting collection "map_reduce_example". Appending the find() command causes the output to be displayed.
The map1() function emits the key-value pair (p, 1), where p is the books.publisher field. So this will generate 19 pairs, one for each books document. ...
Read now
Unlock full access