Hi all,
got a simple map-reduce question. I'm sure I'm not looking at the problem, right.
Currently, I have a map-reduce index which is trying to do the following: For each USER in the system, return the USER + total number of Foo's they have (i.e. a User Summary).
User is a document.
public class User
{
string Id;
string Name;
}
Foo is a document, like:
public class Foo
{
string Id;
string UserId; // e.g. users/1-A
}
For reasons, they are separate documents as such.
Now, if the user has no Foo's, I get a NULL back because my index is sorta this:
public Foo_GetUserSummary()
{
AddMapForAll<Foo>(foos => from f in foos
let user = LoadDocument<User>(f.UserId)
...
select new
{
f.UserId,
..
FooCount = 1
});
Reduce = results => from r in results
group r by new { f.UserId, ... }
into g
select new
{
g.key.UserId,
....
FooCount = g.Sum(x => x.FooCount)
};
}
So i'm guessing that, because User #1 has no Foo's, then user #1 is not part of the result set.
Any thoughts on how I should tackle this problem, please?
cheers!
-PK-