Real map/reduce functionality


#1

As far as I can see you can only extend the current reduce option in couchbase
to an extend that it summarises or counts values (because it’s also stored along the view index)

I would like to f.e. filter out or calculate a certain score for the documents that are found in the mapping phase & only return the ones above a certain score threshold (really lightweight operations server side).

I know you probably will tell me this needs to be done on the application layer side, but in my use case it would be much faster to do it through a UDF or a more custom _reduce function server side as I otherwise need to return 10K to 100K document ids to the application, eventually fetch the contents of all these documents & perform these calculations there.

Riak supports more custom/ real map/reduce functionality are there any plans to support this in couchbase too? What’s the best approach for now to do something like this? Thx


#2

If you’re searching by a single key, then I think you could do it in your view. Maybe not the best way, but sort of a hack for now until couchbase has better map/reduce functionality or they do a production release of the N1QL stuff for all platforms. Assuming you’re using only the properties of each document to calculate its own score. E.g.
if (filter by mapping) {
//calculate score
emit([key,score],null);
}

Then when querying put together a combo key: startKey: [searchKey,minScore], endKey: [searchKey,maxScore]