Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 31150 invoked from network); 14 Aug 2009 16:21:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Aug 2009 16:21:23 -0000 Received: (qmail 83501 invoked by uid 500); 14 Aug 2009 16:21:28 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 83452 invoked by uid 500); 14 Aug 2009 16:21:28 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 83442 invoked by uid 99); 14 Aug 2009 16:21:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Aug 2009 16:21:28 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of wout.mertens@gmail.com designates 209.85.219.215 as permitted sender) Received: from [209.85.219.215] (HELO mail-ew0-f215.google.com) (209.85.219.215) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Aug 2009 16:21:18 +0000 Received: by ewy11 with SMTP id 11so1908114ewy.11 for ; Fri, 14 Aug 2009 09:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=RXCJhT47X4B24SrcGprEo6yeJjlePR/nt8k9ud0GcLo=; b=wH5gfkL5U05Ry0u/+21f4xZOuOOxOUMATrTR8SWs4DGRW2sl8fCG5Ffs+7RiNFXDQQ P+6y2WU9/iBHdAtQJILkxOLwcU0o24PVvTrOV9BS8qMW1GB0+hPqs9Pt6m37HSPIPseU 0oIACrhLFubG5vyyaDF59CZh3wLElXteeLnEg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=pSXY9L5Y1GYy15uPG8kIpp6xY2mS2TFKj8IaNVuARZ0sMXX05CG7TLxa3NC2qYk29n nyKYDu/HSlliNtBChtYLe+/v455dj3oEyvUoY409vyneUxiIwGvKBdSIZNM3Ee768TZm 9K83kh9pygwjRhEDl0uaX0L4ko3zPNOmlgC2o= Received: by 10.211.199.11 with SMTP id b11mr3402848ebq.68.1250266856762; Fri, 14 Aug 2009 09:20:56 -0700 (PDT) Received: from ?192.168.1.14? ([91.179.100.149]) by mx.google.com with ESMTPS id 7sm7903153eyb.0.2009.08.14.09.20.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 14 Aug 2009 09:20:56 -0700 (PDT) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Mime-Version: 1.0 (Apple Message framework v1074) Subject: Re: I'm going mad with reduce From: Wout Mertens In-Reply-To: Date: Fri, 14 Aug 2009 18:20:55 +0200 Content-Transfer-Encoding: 7bit Message-Id: References: To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1074) X-Virus-Checked: Checked by ClamAV on apache.org 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, 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 > >