Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 12473 invoked from network); 16 Jan 2009 14:32:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Jan 2009 14:32:39 -0000 Received: (qmail 65223 invoked by uid 500); 16 Jan 2009 14:32:37 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 65198 invoked by uid 500); 16 Jan 2009 14:32:37 -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 65187 invoked by uid 99); 16 Jan 2009 14:32:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jan 2009 06:32:37 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dundeemt@gmail.com designates 209.85.198.233 as permitted sender) Received: from [209.85.198.233] (HELO rv-out-0506.google.com) (209.85.198.233) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jan 2009 14:32:28 +0000 Received: by rv-out-0506.google.com with SMTP id g37so1619007rvb.35 for ; Fri, 16 Jan 2009 06:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=15gpThka9SjRentkkNYXN+WGawebw262czOQ1qwaAGc=; b=ORnqBH3SGW10kIBR+90sJeACszv98CfGqSV/82AplDpJ8a+5Jjw4alXYnnV/N1n1y3 DtyAcV9wPE+RHWTpHYFIfR5EhRXDhnodGpEc3B5QdQWu6q/Hkk4bloUsrqSY1TsUpxis xIUNk9a4K3Hm+BfvmkVGgtNGbjRGMNd0G8aQc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:content-type; b=Vo0GhZK3R31e1PW9JpDDdnPZisG4GpSTTqva/UuNLCPcYVRqmTlFjNtDWy8bOr31aP fNHeNmjgdzRk9JV/97xDTjZBHetyrM3bsSPiwV/O25ppzlawqlM1sEeiZbYkmLZUajbq FcyFpsshSA6dgB2VSTXOXlwqScLNWBX94I+Ww= MIME-Version: 1.0 Received: by 10.141.23.7 with SMTP id a7mr1245458rvj.238.1232116327599; Fri, 16 Jan 2009 06:32:07 -0800 (PST) Reply-To: tech@dundeemt.com In-Reply-To: References: Date: Fri, 16 Jan 2009 08:32:07 -0600 Message-ID: <5aaed53f0901160632w54b8500ejbd0dfafc8dc082cd@mail.gmail.com> Subject: Re: RE: How to create view to count number of unique values from documents .... ? From: "Jeff Hinrichs - DM&T" To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000e0cd20f26074f6304609a7012 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd20f26074f6304609a7012 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On Fri, Jan 16, 2009 at 5:34 AM, Seledkin Vyacheslav < viacheslav.seledkin@avicomp.com> wrote: > > Thanks for reply, Chris but you gave me no ansver. Please read my question > carefully. I don't want to find how many times any particular tag are > encountered across the documents, but how many unique tags are in documents. > The documented example only gives me ability to request and count the > number of rows in ansver on the client, it is not acceptable because of huge > amount of data. > > > The documented example is the way to do it. It's really slow to > > generate the view the first time, but as you add documents it will > > only need to regenerate the index for those new documents. > > > Chris > > >> On Thu, Jan 15, 2009 at 2:56 AM, Viacheslav Seledkin > >> After reading all docs I think it is not trivial. The task itself: I > have > >> documents with fields > >> .............. > >> doc(N) = { > >> ... > >> tag:"y", > >> tag:"o", > >> tag:"b", > >> tag:"b", > >> tag:"v", > >> tag:"r", > >> ............ > >> } > >> > >> doc(N+1) = { > >> ... > >> tag:"a", > >> tag:"b", > >> tag:"t", > >> tag:"b", > >> tag:"u", > >> tag:"r", > >> ... > >> } > >> > >> doc(N+2)= { > >> ... > >> tag:"t", > >> tag:"m", > >> tag:"i", > >> tag:"b", > >> tag:"l", > >> tag:"z", > >> ........... > >> } > >> ............. > >> and so on... > >> > >> How to create a view that allows to get number of unique tags throught > >> various range of some keys. > >> i.e > >> .. > >> emit(keyN1,"y") - from document doc(N) > >> emit(keyN2,"o") - from document doc(N) > >> .... > >> emit(key(N+2),"z") - from document doc(N+2) > >> .. > >> > >> and view request > >> http://.../_view/?startkey=someStartKey&endkey=someEndKey > >> gives me something like > >> > >> {"rows":[{"key":null,"value":12}]}???? > >> > >> Of course i can use documented example with emit("y",1) and > >> reduce()(return > >> sum(values);) and count the number of rows returned to the client but i > >> have > >> many thousands of tags and it is not effective. Any help appreciated. > >> > >> > If I'm understanding, you will need to do an initial reduction in the primary map function. assuming your tags are in a list structure in the doc... for (var t in doc.tags){ // create associative array (tagcnt) keyed on tag, incrementing count } //emit values from tagcnt here for (t in tagcnt){ emit( ...stuff... ) } Regards, Jeff --000e0cd20f26074f6304609a7012--