Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 99462 invoked from network); 30 Mar 2011 08:32:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Mar 2011 08:32:25 -0000 Received: (qmail 51918 invoked by uid 500); 30 Mar 2011 08:32:23 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 51867 invoked by uid 500); 30 Mar 2011 08:32:23 -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 51859 invoked by uid 99); 30 Mar 2011 08:32:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Mar 2011 08:32:23 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_SOFTFAIL X-Spam-Check-By: apache.org Received-SPF: softfail (athena.apache.org: transitioning domain of mehdi.elfadil@mango-is.com does not designate 209.85.210.52 as permitted sender) Received: from [209.85.210.52] (HELO mail-pz0-f52.google.com) (209.85.210.52) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Mar 2011 08:32:17 +0000 Received: by pzk12 with SMTP id 12so272054pzk.11 for ; Wed, 30 Mar 2011 01:31:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.149.21 with SMTP id w21mr660525wfd.431.1301473916186; Wed, 30 Mar 2011 01:31:56 -0700 (PDT) Received: by 10.142.13.9 with HTTP; Wed, 30 Mar 2011 01:31:56 -0700 (PDT) X-Originating-IP: [193.191.180.231] In-Reply-To: References: Date: Wed, 30 Mar 2011 10:31:56 +0200 Message-ID: Subject: Re: Querying a view with a complex key with a wildcard From: Mehdi El Fadil To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000e0cd327d2756f87049faf02b5 --000e0cd327d2756f87049faf02b5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable hi, You can have a look at the section "View \ *Reversed result*" from the couchdb guide to understand why it did not work with your start key and descending order: http://guide.couchdb.org/editions/1/en/views.html Good luck, mehdi On Tue, Mar 29, 2011 at 9:17 PM, Mclendon, William C III wrote: > > > On 3/29/11 12:43 PM, "Paul Davis" wrote: > > >On Tue, Mar 29, 2011 at 2:39 PM, Mclendon, William C III > > wrote: > >> Hi, > >> > >> I've got a view that is built from a map.js that looks like this: > >> > >> function(doc) > >> { > >> if(doc['record type']=3D=3D'search') > >> { > >> emit( [doc.status, doc.time], doc ) > >> } > >> } > >> > >> Where the doc.status field is a string that is either "Running" or > >>"Finished" and doc.time is a floating point value from 0 and up > >>representing the time a task took to complete. > >> > >> I'd like to be able to query the documents that are 'Finished' and sor= t > >>by time. This query works: > >> > >> ... /_view/searches_by_status?startkey=3D["Finished",0]&include_docs= =3Dtrue > >> > >> But it doesn't sort=C5=A0 So if I change it to: > >> > > > >How do you mean, doesn't sort? I assure you its sorted, but most > >likely just not sorted as you expect. > > Well, yea... it's in ascending order be default since descending=3Dfalse = is > the default. I'd like descending order so my keys would be in an orderin= g > something like this: > > ["Finished", 83.2] > ["Finished", 77.3] > ["Finished", 43.2] > ... > ["Finished", 0] > > If I run the view in futon, I can change the ordering of the key field in > the table and see the right thing but I'd like to get this out of my view > query through the URI as well. > > > >> ... > >>/_view/searches_by_status?startkey=3D["Finished",0]&include_docs=3Dtrue= &desce > >>nding=3Dtrue > >> > >> Then I only get values containing time=3D0 > >> > >> Why does adding the descending=3Dtrue option change the results? > >> > >> I've also tried this: > >> > >> =C5=A0 > >>/_view/searches_by_status?startkey=3D["Finished",0]&endkey=3D["Finished= ",9999 > >>.9999]&include_docs=3Dtrue&descending=3Dtrue > >> > >> But this one doesn't return anything. > >> > >> Is there a way to query this view to get records with a particular > >>value in the doc.status field and still sort the fields? > >> > > > >/_view/searches_by_status?startkey=3D["Finished"]&endkey=3D["Finished",{= }]&inc > >lude_docs=3Dtrue > > > >This will return rows sorted by doc.time in ascending order. > > > >/_view/searches_by_status?startkey=3D["Finished",{}]&endkey=3D["Finished= "]&inc > >lude_docs=3Dtrue&descending=3Dtrue > > > >Will return docs sorted descending by doc.time. > > Ah, this works! > > I'm sure it's obvious that I'm fairly new to couchdb... Where might I go > to look up what's happening with the {} values in the key? I've picked > through the couchdb wiki a bit and have a couple couchdb books but haven'= t > run across an explanation of this info in my searches :( > > Thanks! > > > >> Thanks in advance for any advice and/or help! > >> -William > >> > > > --000e0cd327d2756f87049faf02b5--