I am trying to create a very basic map-reduce example that also incorporates a query in the MapReduce api call.
My collection has lots of entries formatted as follows:
{ "_id" : { "$binary" : "PdYV4WMTAEyYMQHXJZfzvA==", "$type" : "03" },
"firstname" : "Matthew",
"surname" : "Chambers",
"email" : "" }
The code is as follows:
var map = @"
function() {
emit(this.surname, { count : 22 });
}";
var reduce = @"
function(key, emitValues) {
return { count : emitValues[0].count };
}";
List<BsonValue> contactIds = new List<BsonValue>();
contactIds.Add(new Guid("A04FC88D-7BF7-443D-B5C3-EB11EE2B36DF"));
contactIds.Add(new Guid("26B690B3-5ED7-47F4-A878-3906E28BBC58"));
MongoDB.Driver.Builders.QueryConditionList queryList = MongoDB.Driver.Builders.Query.In("_id", BsonArray.Create(contactIds));
//var mr = personCollection.MapReduce(map, reduce);// THIS WORKS!
var mr = personCollection.MapReduce(queryList, map, reduce); // THIS FAILS
It all works if I don't include the queryList in the MapReduce call. However, if I do include the queryList then I get the following runtime error:
Command 'mapreduce' failed: db assertion failure (response: { "assertion" : "'out' has to be a string or an object", "assertionCode" : 13606, "errmsg" : "db assertion failure", "ok" : 0 }) at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](IMongoCommand command) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 621 at MongoDB.Driver.MongoCollection.MapReduce(BsonJavaScript map, BsonJavaScript reduce, IMongoMapReduceOptions options) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 788 at MongoDB.Driver.MongoCollection.MapReduce(IMongoQuery query, BsonJavaScript map, BsonJavaScript reduce) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 823 at HPSLucene.Models.Mongo.MapReduce() in C:\Inetpub\wwwroot\HPSLucene\HPSLucene\Models\Mongo.cs:line 158
Anyone know what the problem is? Thanks very much.