I am trying to create a very simple example of map reduction, which also includes a request in the api call of MapReduce.
My collection has many 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(queryList, map, reduce);
Everything works if I do not include queryList in the MapReduce call. However, if I turn on queryList, I get the following runtime error:
'mapreduce' failed: db assertion failure (response: { "assertion": "out" "," assertionCode ": 13606," errmsg ":" db assertion failure "" ok": 0}) MongoDB.Driver.MongoDatabase.RunCommandAs [TCommandResult] ( IMongoCommand) C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoDatabase.cs: 621 MongoDB.Driver.MongoCollection.MapReduce( BsonJavaScript, BsonJavaScript , IMongoMapReduceOptions) C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs: 788 MongoDB.Driver.MongoCollection.MapReduce( IMongoQuery, BsonJavaScript, BsonJavaScript ) C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs: 823 HPSLucene.Models.Mongo.MapReduce() C:\Inetpub\wwwroot\HPSLucene\HPSLucene\Models\Mongo.cs: 158
- , ? .