I’ve heard great things about Map Reduce but never had a use case for it until today. So I spent the last couple hours playing around with it and trying to follow the various Map Reduce tutorials out there. I probably read about 12 different tutorials and found none that gave me all the details I needed.
The most helpful was actually the official Mongo MapReduce documentation.
This example probably won’t tell you everything you need either, but I’m putting it out there as one more piece of the puzzle. It’s complete and running code which creates the data needed and runs the map reduce on generated data.
The situation that came up is something that would’ve been handled with a LEFT JOIN WHERE $something IS NULL pattern in MySQL.
Code with comments follows. To play with it on your own, download it here.