How to use map/reduce to handle more than 10000 unique keys for grouping in MongoDB?
Posted
by Magnus Johansson
on Stack Overflow
See other posts from Stack Overflow
or by Magnus Johansson
Published on 2010-04-08T12:14:13Z
Indexed on
2010/04/08
12:33 UTC
Read the original article
Hit count: 524
mongodb
I am using MongoDB v1.4 and the mongodb-csharp driver and I try to group on a data store that has more than 10000 keys, so I get this error:
assertion: group() can't handle more than 10000 unique keys
using c# code like this:
Document query = new Document().Append("group",
new Document()
.Append("key", new Document().Append("myfieldname", true))
.Append("$reduce",
new CodeWScope(
"function(obj,prev) { prev.count++; }"))
.Append("initial", new Document().Append("count", 0))
.Append("ns", "myitems"));
I read that I should use map/reduce, but I can't figure out how. Can somebody please shed some light on how to use map/reduce?
Or is there any other way to get around this limitation?
Thanks.
© Stack Overflow or respective owner