Executing MapReduce in Mongo using PyMongo
In our previous recipe, Implementing aggregation in Mongo using PyMongo, we saw how to execute aggregation operations in Mongo using PyMongo. In this recipe, we will work on the same use case as we did for the aggregation operation but we will use MapReduce. The intent is to aggregate the data based on the state names and get the top five state names by the number of documents that they appear in.
Programming language drivers provide us with an interface to invoke the map reduce jobs written in JavaScript on the server.
Getting ready
To execute the map reduce operations, we need to have a server up and running. A simple single node is what we need. Refer to the Installing single node MongoDB recipe from Chapter 1, Installing and Starting the Server for instructions on how to start the server. The data that we will operate on needs to be imported in the database. The steps to import the data are mentioned in the Creating test data recipe in Chapter...