incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Clairon <>
Subject group_level and sorting
Date Sat, 18 Apr 2009 16:52:05 GMT
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 :
  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 = [];
        for( var v in values){
            if (results.indexOf( values[v] ) < 0){results.push(values[v]);}
        for( var i in values){
            for(var e in values[i]){
    return results;

$ curl http://localhost:5984/db/_design/foo/_view/by_tag_sort_by_date?reduce=false

returns :


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


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 ?



View raw message