Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 19744 invoked from network); 18 Apr 2009 16:52:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Apr 2009 16:52:35 -0000 Received: (qmail 29013 invoked by uid 500); 18 Apr 2009 16:52:34 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 28928 invoked by uid 500); 18 Apr 2009 16:52:34 -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 28918 invoked by uid 99); 18 Apr 2009 16:52:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Apr 2009 16:52:34 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of clairon@gmail.com designates 209.85.218.218 as permitted sender) Received: from [209.85.218.218] (HELO mail-bw0-f218.google.com) (209.85.218.218) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Apr 2009 16:52:27 +0000 Received: by bwz18 with SMTP id 18so1443979bwz.11 for ; Sat, 18 Apr 2009 09:52:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=lfGAL9R3OpOXFylRLdxSyRWdIUYbKiX0eqOeawJhcRk=; b=Orhbkri5stvLAGhiRyE7ihNdY8Arcq+0tdtAwiBq/1WI+xTKGgtESH5XpYo9QCF1je geyQ1wNySCumcfWo2SIHq6ahUaewG3Jb/jUOX3syH04VO0v50pKtSe+jrLG6rXPvrrTB AzS8qVovlwg080WYijLQHuIaI0jUOy4eBtozM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=yAiPt1Vr/qsRlM+URjm5s3jOvAdLIB1petTfTgz4jAvyDAm9NUa4NmdmoxEcx/eGdA +ftqL8Wia3eLtZjwPseyyuJ7sWr6RjucEEZbMLXGxitwy52BJjDnPMXTIxbc3a/QUi6b c9DjrTS2gp39SCrBx7LqkK5cP/9Dlda5C0ujw= MIME-Version: 1.0 Received: by 10.103.193.12 with SMTP id v12mr2097935mup.23.1240073525701; Sat, 18 Apr 2009 09:52:05 -0700 (PDT) Date: Sat, 18 Apr 2009 18:52:05 +0200 Message-ID: <4b307fd10904180952jdb6d14ob1d8ed4cb85b1eab@mail.gmail.com> Subject: group_level and sorting From: Nicolas Clairon To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi all ! I have a question (wich is a big concerne to me and my project) about the group_level option. I want to display all doc by tag and then sorting them by date. The map function : ----------------------------------- function(doc){ for(var t in doc.tags){ emit([doc.tags[t], doc.creation_date], doc.title); } } ------------------------------------ * creation_date is a float since the epoch (ie something like this 12423344.003) * docs can have the same title the reduce function: ----------------------------------- function(key, values, rereduce){ var results = []; if(!rereduce){ for( var v in values){ if (results.indexOf( values[v] ) < 0){results.push(values[v]);} } } else{ for( var i in values){ for(var e in values[i]){ results.push(values[i][e]); } } } return results; } ----------------------------------- $ curl http://localhost:5984/db/_design/foo/_view/by_tag_sort_by_date?reduce=false returns : {"id":"8075ba2ef7418f4d6c9a3e89be83acd8","key":["tag1",1239361935.000004],"value":"title2"}, {"id":"8d9132318a6c34c646e9e2cd43823ffa","key":["tag1",1239794744.000002],"value":"title1"}, {"id":"f49a28ffd2118298c1be7440ec4556fa","key":["tag2",1239794744.000002],"value":"title1"}, this is ok because title1 is newer than title2. But now, I want all displayed by tag so I use the group_level : $ curl http://localhost:5984/db/_design/foo/_view/by_tag_sort_by_date?group_level=1 {"key":["tag1"],"value":["title1","title2"]}, {"key":["tag2"],"value":["title1"]}, I have all titles by tag but the docs is not sorted by date anymore... Does group_level keeps the absolute sorting ? Does the sort break anyway ? Thanks, Nicolas