From couchdb-user-return-1473-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Sun Oct 05 19:34:11 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 81986 invoked from network); 5 Oct 2008 19:34:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Oct 2008 19:34:11 -0000 Received: (qmail 62393 invoked by uid 500); 5 Oct 2008 19:34:09 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 62368 invoked by uid 500); 5 Oct 2008 19:34:09 -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 62357 invoked by uid 99); 5 Oct 2008 19:34:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2008 12:34:09 -0700 X-ASF-Spam-Status: No, hits=2.5 required=10.0 tests=DNS_FROM_DOB,DNS_FROM_SECURITYSAGE,RCVD_IN_DOB,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [83.97.50.139] (HELO jan.prima.de) (83.97.50.139) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2008 19:33:03 +0000 Received: from [10.0.1.6] (e178224248.adsl.alicedsl.de [::ffff:85.178.224.248]) (AUTH: LOGIN jan, TLS: TLSv1/SSLv3,128bits,AES128-SHA) by jan.prima.de with esmtp; Sun, 05 Oct 2008 19:21:36 +0000 Message-Id: <60FF2718-50A6-4909-BEA2-B9B5E8F74533@apache.org> From: Jan Lehnardt To: couchdb-user@incubator.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v928.1) Subject: Re: Sorting views with composite keys Date: Sun, 5 Oct 2008 21:21:04 +0200 References: <27d8d0930810051135j7f736c87g4b48bdbf3c86dedd@mail.gmail.com> X-Mailer: Apple Mail (2.928.1) X-Virus-Checked: Checked by ClamAV on apache.org In my defense :) My suggestion was a 3 minute hack that was done without much thinking. If we want to go that route, we'd need to add more sorting handlers for other data types. this could go into a view-JS standard library (like sum()). the use-case was just having the sorting by first and second key, but only ever query on the first one. I'm not claiming that this is a stellar idea, only one that might be feasible for a specific use case. Cheers Jan -- On Oct 5, 2008, at 20:48 , Chris Anderson wrote: > yeah you'd have to preprocess the keys with a similar function.. > > I think the use case is that you'd query based on the front key, and a > count, so as to get, say the last 10 alphabetical tags for a given > user. > > Come to think of it, I'm not sure what sense there is in doing this. > Why not just use a regular collation, and if you have more per > front-key than you can fit in ram, just page through the front key's > second key in reverse... > > > On Sun, Oct 5, 2008 at 11:35 AM, Ayende Rahien > wrote: >> How does querying those works?I mean, the keys wouldn't match, >> would they? >> >> On Sun, Oct 5, 2008 at 8:26 PM, Chris Anderson >> wrote: >> >>> Jan posted this to the IRC channel. >>> >>> http://friendpaste.com/rc9CcxUW >>> >>> I supposed you'd have to write a reverse method for each JS >>> primitive >>> type, if you wanted to be completely flexible. >>> >>> >>> On Sun, Oct 5, 2008 at 9:25 AM, Nick Johnson >>> wrote: >>>> How would I construct a view with two keys, a and b, sorted first >>>> by a >>>> ascending, then by b descending? Composite keys are easy enough to >>> generate, >>>> but the key [a,b] would only permit sorting both in ascending >>>> order (or >>> both >>>> in descending order, if we scan in reverse). Can anyone suggest a >>>> way of >>>> modifying the keys to support heterogenous sort orders like this? >>>> My best >>>> idea so far is a monstrosity involving hex-encoded binary data. :) >>>> >>> >>> >>> >>> -- >>> Chris Anderson >>> http://jchris.mfdz.com >>> >> > > > > -- > Chris Anderson > http://jchris.mfdz.com >