Try N1QL: http://www.couchbase.com/communities/n1ql
On Monday, May 26, 2014 10:32:32 AM UTC-7, Aliaksey Kandratsenka wrote: > > > > > On Mon, May 26, 2014 at 8:16 AM, Prakash <[email protected] <javascript:> > > wrote: > >> I have SQL query like this: >> >> select count(id) as ct, city from table group by city order by ct desc >> >> How can I perform this query in Couchbase? I have map function like This: >> >> function (doc, meta) { >> if(doc.city!==null) { >> emit(doc.city,1) >> } >> } >> >> and reduce: >> >> _count >> >> my query url is like this: _view/q7?group_level=1&descending=true but it >> it sort only for key not for value. >> >> No one had answer this here >> >> >> http://stackoverflow.com/questions/23410708/how-to-do-order-in-groupingaggregation-in-couchbase >> > > I believe it's impossible with couchdb-style views. Here's why. > > What you need appears to require two sorting passes. One to group by city > and get counts and another to sort by counts. And couchdb-style views only > do one sorting (as part of placing view results into btree). > > If only we could have views from views, then you could describe such > dual-pass "topology" easily. > > -- You received this message because you are subscribed to the Google Groups "Couchbase" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
