Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 61754 invoked from network); 17 Jul 2008 15:48:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jul 2008 15:48:19 -0000 Received: (qmail 64959 invoked by uid 500); 17 Jul 2008 15:48:17 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 64925 invoked by uid 500); 17 Jul 2008 15:48:17 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 64914 invoked by uid 99); 17 Jul 2008 15:48:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2008 08:48:17 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of peter.eddy@gmail.com designates 209.85.132.243 as permitted sender) Received: from [209.85.132.243] (HELO an-out-0708.google.com) (209.85.132.243) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2008 15:47:24 +0000 Received: by an-out-0708.google.com with SMTP id b38so141337ana.83 for ; Thu, 17 Jul 2008 08:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=Y7z6l2R3s56HHESw4cRtR1ZFxmLOxUGP6zuU4dIKrQI=; b=OkCNM7QFNBsaj+FPUSVMz/7Djwg/0zkhjqhz1VSn3plLEaNdOckb+M2cnyUm8BYBe/ 3TBEDj2IJspHKXjEZcscDF4P/ra7Anp4NFCLcJpsgpnC/jadu18ii+iy4N0q2rohwDQ9 L+x0CIMd2M2DRVLymtZAocmZ5tahoa8y97P3E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=lsFWgYAgQdaNVTpMIRLopsNkrYISmpmkSvLgGoYZa25r01/1Wx7+GlHznIvl3LxhIW YKu2aM1MG8ZSpiuDrOowufRcdZOx1YwEN00yLdyBE3m6ojxvTK8JRvML+7ehUoYQR3i0 FqYi+ctdQCp824BLqco6p50gqwLydqz+b9muo= Received: by 10.100.112.9 with SMTP id k9mr4263109anc.111.1216309668409; Thu, 17 Jul 2008 08:47:48 -0700 (PDT) Received: by 10.100.108.14 with HTTP; Thu, 17 Jul 2008 08:47:48 -0700 (PDT) Message-ID: <5aea26870807170847k270b2438n411eea3eb371f6ef@mail.gmail.com> Date: Thu, 17 Jul 2008 11:47:48 -0400 From: "Peter Eddy" To: couchdb-user@incubator.apache.org Subject: Re: more newbie questions - how to use more than one key in views In-Reply-To: <71DAC66D-E24B-4C83-9668-DDBDA3F7C456@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <71DAC66D-E24B-4C83-9668-DDBDA3F7C456@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org I've done this using an array in emit(), like so: emit( [doc.title_slug,doc.language,doc.user_id], doc ); - Peter On 7/17/08, Sho Fukamachi wrote: > Hi all, > > another n00b view question from an SQL refugee. > > I can't figure out how to use views to search for documents by more > than one criterion. For example, I have a node-type content DB with > various properties - user_id, title_slug, and language. > > What I can't figure out is how to select by more than one of them at a > time dynamically, rather than having hard-coded views. > > For example, what I'm doing right now is something like this: > > "map" => "function(doc) { if (doc.type == 'content_node' && > doc.langauge == 'en_AU') emit(doc.title_slug, doc); }" > > Problem is I need an additional filter in there and I'm not sure how > to get it in - and it's far from ideal to hardcode the language. Can I > have more than one key in the emit function? Any examples of this kind > of thing anywhere? > > I mean, what I really want to do is > > "function(doc) { if (doc.type == 'content_node' ) > emit((doc.title_slug, doc.language, doc.user_id), doc); }" > > but somehow I don't think it works like that. > > Any hints? Examples of similar solutions? Or, just as welcome, > suggestions that I am coming at this from a totally wrong direction > and advice on what I should really be doing? > > thank you, > > Sho