Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 27853 invoked from network); 29 Mar 2011 17:07:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Mar 2011 17:07:00 -0000 Received: (qmail 41542 invoked by uid 500); 29 Mar 2011 17:06:58 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 41510 invoked by uid 500); 29 Mar 2011 17:06:58 -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 41502 invoked by uid 99); 29 Mar 2011 17:06:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2011 17:06:58 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rgabo@rgabostyle.com designates 209.85.214.52 as permitted sender) Received: from [209.85.214.52] (HELO mail-bw0-f52.google.com) (209.85.214.52) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2011 17:06:50 +0000 Received: by bwj24 with SMTP id 24so527606bwj.11 for ; Tue, 29 Mar 2011 10:06:30 -0700 (PDT) Received: by 10.204.82.166 with SMTP id b38mr4922474bkl.207.1301418390234; Tue, 29 Mar 2011 10:06:30 -0700 (PDT) Received: from [192.168.1.208] (catv-89-132-175-14.catv.broadband.hu [89.132.175.14]) by mx.google.com with ESMTPS id q18sm3576966bka.3.2011.03.29.10.06.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Mar 2011 10:06:28 -0700 (PDT) Sender: Gabor Ratky Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: how to get documents by two or more keys? From: Gabor Ratky In-Reply-To: Date: Tue, 29 Mar 2011 19:06:26 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <7FC4497E-BF26-42DF-872D-3103ED73F3BD@secretsaucepartners.com> References: To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1084) X-Virus-Checked: Checked by ClamAV on apache.org The only thing to add is that the view indexes are sorted by your = (possibly complex) keys. You always retrieve a contiguous portion of the = view by either using just ?key=3D or both startkey and endkey. Depending on the actual data you want to filter / sort / aggregate by, = you can always come up with 'smart' complex keys where the data you need = ends up together, one query away. An example would be to retrieve a single user's posts from 2011 = Feburary. If your keys contain [username, date_posted] and your dates = strings sort chronologically, you can easily query for all posts posted = by a single user in a timeframe: ?startkey=3D["nils", = "2011-02-01"]&endkey=3D["nils","2011-02-28"] If instead, you would also want ALL posts from february from all users, = you would index by having the date come first, so = ?startkey=3D["2011-02-01"]&endkey=3D["2011-02-28"] yields exactly what = you want. On Mar 29, 2011, at 8:25 AM, Nils Breunese wrote: > Keys can be so called 'complex' keys. You could emit [username, tag] = as the key for your view entries and then request = /_design/designname/_view/by_username_and_tag?key=3D["username","tag"] = to do the lookup. >=20 > Nils. > ________________________________________ > Van: bryan rasmussen [rasmussen.bryan@gmail.com] > Verzonden: dinsdag 29 maart 2011 8:03 > Aan: user@couchdb.apache.org > Onderwerp: how to get documents by two or more keys? >=20 > As per the subject - most of my requests can be done with simple views > but I have some cases where I will want to return for multiple keys - > for example where I want to return documents for a username where > there is a particular tag value? >=20 > Thanks, > Bryan Rasmussen > = ------------------------------------------------------------------------ > VPRO www.vpro.nl > = ------------------------------------------------------------------------