Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 68843 invoked from network); 1 Nov 2010 17:10:42 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Nov 2010 17:10:42 -0000 Received: (qmail 40824 invoked by uid 500); 1 Nov 2010 17:11:12 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 40778 invoked by uid 500); 1 Nov 2010 17:11:12 -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 40770 invoked by uid 99); 1 Nov 2010 17:11:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Nov 2010 17:11:11 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.160.180 as permitted sender) Received: from [209.85.160.180] (HELO mail-gy0-f180.google.com) (209.85.160.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Nov 2010 17:11:05 +0000 Received: by gyg8 with SMTP id 8so3614250gyg.11 for ; Mon, 01 Nov 2010 10:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=n4tO5WNT8NuAPOoQtNSATvucQAxGKFTqRWDBtIBo0Lw=; b=Wtk7m5Tdww3pN8o3xMKxWfWGPMONkD8TpBIa4IeYYQwtJss7SyTBIprPMKWzMzSJva zX2ESHbLaC/mjUR8B0GzdxEc8m2fFVgF1Z3BAx7WsrGOf91H6ryQfCw2vu4CcYNMAy27 qeE7gZsbKB5nmX5bNfAvuNFk8QUeM2Ic2r6Do= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=w0695SR+MWOCvp8iQc08SERtxanbjBdh7AS4xR13RDmoBqlQUFaqNO/Q73pY0m+QCI CYfW3krgN7Yc2QTTM7ixJjftZhgFC75qzvrFI6gAczSEwrRXUDveuf8V6bPcngLrg6di ak1McCdLtBepfiMRi8w9xbcjSt3n2Krh3EmJk= Received: by 10.42.175.136 with SMTP id ba8mr1502082icb.13.1288631444047; Mon, 01 Nov 2010 10:10:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.36.130 with HTTP; Mon, 1 Nov 2010 10:10:03 -0700 (PDT) In-Reply-To: <4CCEF12B.8060508@free.fr> References: <4CCEF12B.8060508@free.fr> From: Paul Davis Date: Mon, 1 Nov 2010 13:10:03 -0400 Message-ID: Subject: Re: Complex keys and ranges To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Mon, Nov 1, 2010 at 12:56 PM, cdr53x wrote: > Hello, > > I've read all the docs/wiki again but cannot find anything related to vie= ws > usage when keys are complex JSON objects. > > Especially, there are no explanations nor examples of how the ranges ( > startkey/endkey ) are supposed to behave with complex keys. > > For instance let's presume we have the a view with the following map > function : > > function(doc) { > =A0 =A0... > =A0 =A0emit({ 'date' : created_at =A0, 'author' : author}, null) ; > } > > > Would it be possible to "filter" on both date and author ? > > For instance get all the docs created in a given time range by a given > author , by passing a range like =A0: > > =A0start_key : { 'date' : '201002030000.' , author : 'adams' } > =A0end_key =A0 : { 'date' : '201003030000.' , author : 'adams' } > > ? > > I have tried this however it does not seem to work that way, so if anyone > has some info on how this should work, I'd really appreciate > > Thanks in advance, > > cdrx > View collation is specified here: http://wiki.apache.org/couchdb/View_collation#Collation_Specification In short, no, its not possible to filter on multiple members of an object key. Generally speaking you shouldn't use object keys as they can lead to confusing behavior that is dependent on the various JSON libraries used for serialization. If you need complex keys its generally best to stick to Arrays as their sorting behavior easier to reason about. HTH, Paul Davis