mongodb get distinct records

There is a distinct command in mongodb, that can be used in conjunction with a query. However, I believe this just returns a distinct list of values for a specific key you name (i.e. in your case, you’d only get the id values returned) so I’m not sure this will give you exactly what you want if you need the whole documents – you may require MapReduce instead.

Documentation on distinct:
http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Distinct

Leave a Comment