Created
August 13, 2011 16:02
-
-
Save JakubOboza/1143985 to your computer and use it in GitHub Desktop.
MongoDB Sample MapReduce in a file with usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mongo localhost:27017/data_gatherer test.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var map = function(){ | |
emit(this.url, 1); | |
} | |
var reduce = function(key, values){ | |
var res = 0; | |
values.forEach(function(v){ res += 1}); | |
return {count: res}; | |
} | |
db.sites.mapReduce(map, reduce, { out: "mapped_urls" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment