Many to many relationship between documents with map reduce views

Hi I have two type of documents, say Swimmer and Race.
Here are some swimmer documents:

{
"_class":“Swimmer”,
“swimmerId”:“111”,
“name”:“Michael Phelps”,
“races”:[“123”,“124”,“125”]
}

And some race documents:

{
"_class":“Race”,
“raceId”:“123”,
“name”:“Fina Budapest”,
“distance”:100
},
{
"_class":“Race”,
“raceId”:“124”,
“name”:“Fina Ukraine”,
“distance”:1500
}

I need to create many-to-many relationship but at first, one-to-many relationship is OK. My goal is to query a view for all the races (whole race object) of a swimmer with given swimmerId.

I tried to write some map functions with no success. The missing part is how to simulate join with race id and the race document?

The result should be sth like this when key 111 (swimmerId) is queried:

111 ->
{
"_class":“Race”,
“raceId”:“123”,
“name”:“Fina Budapest”,
“distance”:100
},
{
"_class":“Race”,
“raceId”:“124”,
“name”:“Fina Ukraine”,
“distance”:1500
}

My map function is:

function(doc, meta) {
if (doc._class == ‘Swimmer’) {

    if (doc.races) {

        for (var i in doc.races) {

            emit([meta.id, doc.races[i]], null);
        }
    }

} else if (doc._class == 'Race') {
    emit(meta.id, doc);
}

}

you need reduce, page 18 , FYI

Documentation says this:

But it is legal to return an array or dictionary, and sometimes people have tried to make reduce functions that transform the input values without actually making them any smaller. The problem with this is that it scales badly, and as the size of the index grows, the indexer will eventually run out of memory and fail.

So, combining the results into a list or collection will not be proper in reduce function. What will be the reason for using a reducer?

Isn’t there a built-in solution for combining the values with the same key?

How about N1QL? it is easy to use N1QL to join two documents on keys.

In fact this was my first attempt for solving the problem. But in another question, I got a response saying, “use mapreduce views if the mission is time-critical”. That’s why I am trying to solve without N1QL queries.