Why don't you simply emit a row for each value in Standard? That will then become unique rows in the reduce. You'll have to read multiple rows to get all the values though.

Wout.

On Aug 14, 2009, at 3:41 PM, [email protected] wrote:

Dear users,

I like to provide check-box input with a view.
The couchdb contains  an key named Standard with
90 values "CE3", 2 values "SE2", 1 value "C1" ...

Now the view should deliver each value 1 times.
After two hours playing with reduce I give up at this point:

map:function(doc) {
if(doc.Calibration.Standard){
var standard = doc.Calibration.Standard;
;
 emit(standard, {"Standard": standard });
}
}
reduce:function(k, v, c){

var res = {};
var star = new Array();
var j =0;

for(var i=0; i< v.length; i++) {

var stdr = v[i].Standard;

if(!(res[stdr])){

res[stdr] = ;
star[j] = v[i].Standard;
j +=1;

}

}
var conStr = star.toString();
var back = {Standard:conStr}
return back ;

}

I get something like
{"rows":[
{"key":null,"value":{"Standard":"CE3,SE2,CE3,CE2,CE1"}}
]}


When I use the "raw" http://server:5984/db/_design/reduce/_view/standard-1
you see that CE3 is listed two times ??

I think this is a kick self problem,
can you kick me?

Regards
Thomas



Reply via email to