From user-return-7892-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sun Dec 06 06:25:27 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 74853 invoked from network); 6 Dec 2009 06:25:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Dec 2009 06:25:27 -0000 Received: (qmail 22912 invoked by uid 500); 6 Dec 2009 06:25:26 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 22810 invoked by uid 500); 6 Dec 2009 06:25:25 -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 22799 invoked by uid 99); 6 Dec 2009 06:25:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Dec 2009 06:25:25 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kamyar.n@gmail.com designates 209.85.219.225 as permitted sender) Received: from [209.85.219.225] (HELO mail-ew0-f225.google.com) (209.85.219.225) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Dec 2009 06:25:22 +0000 Received: by ewy25 with SMTP id 25so2125993ewy.25 for ; Sat, 05 Dec 2009 22:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=Lsg835PEcLncBN71hIcU91gBYQOE8tqkT+XSAnvJLdM=; b=Tg/MRvTPJ/pZ44i4pBtiwbKzTB4h+/vpyapP7qTrSBiCC/T1Dsnq6gBYam5jP8Ubmd SnRapLmaXdPUkAH6p6bzDxnpfZfhT6mc51k0rSkyhC5FwuRUAzZjqTCFNweDhsxvByxu 41dUt6SqoOAYE4hEyA9SfhjrLKkR95pZAT9wY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=D0OqaqTkHOvF3XtlSWtoYjCqP7bGUBB0GcYc6PpsiVAQRIPXRmP1KqlaDBd3dfoIii mDZmsiBvsdIHRATioEDL7VVBa+m/lKRf00w5TBOHFMerCwCojrq4e4OB0crJzRn7YM36 RctzmHtzTFeNoC7tQxkNerFPetbuaxCM8tEb0= MIME-Version: 1.0 Received: by 10.216.88.143 with SMTP id a15mr1784174wef.206.1260080700898; Sat, 05 Dec 2009 22:25:00 -0800 (PST) In-Reply-To: References: <1df0d0a40912052055s2b3d8983la2295a399a2b050a@mail.gmail.com> Date: Sun, 6 Dec 2009 09:55:00 +0330 Message-ID: <1df0d0a40912052225g16159c7fj720a30e2a1a2f4c3@mail.gmail.com> Subject: Re: newbie question: reduce/group_level From: Kamyar Navidan To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016e6d6454e90bee1047a09664e --0016e6d6454e90bee1047a09664e Content-Type: text/plain; charset=UTF-8 Thank you for your response. So in general [x1, x2, ... , xn-1] gets precedence over [x1, x2, ... , xn-1, xn] where x1...xn-1 is identical. Am I getting this right? On Sun, Dec 6, 2009 at 9:01 AM, Chris Anderson wrote: > On Sat, Dec 5, 2009 at 8:55 PM, Kamyar Navidan wrote: > > Reading through Couchdb: The Definitive Guide I came across this section > in > > chapter 06 : > > > > In the blog app, we use group_level reduce queries to compute the count > of > >> comments both on a per-post and total basis, achieved by querying the > same > >> view index with different methods. With some array keys, and assuming > each > >> key has the value 1: > > > > > >> ["a","b","c"] > > > > ["a","b","e"] > > > > ["a","c","m"] > > > > ["b","a","c"] > > > > ["b","a","g"] > > > > > >> The reduce view: > > > > > >> function(keys, values, rereduce) { > > > > return sum(values) > > > > } > > > > > >> returns the total number of rows between the start and end key. So with > >> startkey=["a","b"]&endkey=["b"] (which includes the first 3 of the above > >> keys) the result would equal 3. > > > > > > Earlier in chapter it is stated that: > > > > The startkey and and endkey parameters specify an inclusive range on > which > >> we can search. > > > > There is an inclusive_endkey=true http query parameter you can use. > > > > > So how come the fourth and fifth rows that satisfy endkey=["b"] condition > > are not included in results? I guess I am missing something here. Can > > somebody please clarify this for me. > > > > In this case, only the keys: > > ["a","b","c"] > ["a","b","e"] > ["a","c","m"] > > are included in the range. > > the key ["b","a","c"] comes after ["b"] so it is not included. ["b"] > itself would match. > > Chris > > > > > > -- > Chris Anderson > http://jchrisa.net > http://couch.io > --0016e6d6454e90bee1047a09664e--