Skip to content

Instantly share code, notes, and snippets.

@jridgewell
Last active December 18, 2015 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jridgewell/5809098 to your computer and use it in GitHub Desktop.
Save jridgewell/5809098 to your computer and use it in GitHub Desktop.
mapReduce geoSpacial in Mongo
require 'mongo_mapper'
map = %Q(function() {
lat_long = Math.floor(this.lat) + Math.floor(this.lon);
emit(lat_long, this.id);
})
reduce = %Q(function(id, values) {
return vals;
})
output_collection = "database.1by1"
collection.map_reduce(map, reduce, :out => output_collection).find()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment