couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Bock <thsteinb...@web.de>
Subject Re: I'm going mad with reduce
Date Sat, 15 Aug 2009 07:52:26 GMT
Thank you for answering but ...


 >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.

... I don`t understand. Maybe I haven't described the Problem not well.
The docs with doc.Standard have:
{
Type: KK,
Sign:1111,
Standard:CE3,
.
.
.
}
This means that I have only one kind of Standard in a doc. I think its
right that it is not possible to conserve information from doc to doc on the map side. Therefore
I have to emit the Standard value ...   


 >
 >Wout.
 >
 >On Aug 14, 2009, at 3:41 PM, Thomas.Bock@ptb.de 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
 >>

________________________________________________________________
Neu: WEB.DE Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://produkte.web.de/go/02/


Mime
View raw message