couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabio Forno <>
Subject Re: counting rows in range queries
Date Thu, 30 Jul 2009 07:56:43 GMT
On Thu, Jul 30, 2009 at 9:15 AM, Paul Davis<> wrote:
> On Thu, Jul 30, 2009 at 2:53 AM, Fabio Forno<> wrote:
>> On Thu, Jul 30, 2009 at 3:22 AM, Paul Davis<> wrote:
>>> My bad, that should read 'emit([doc.bucket,], value)'
>> Well but it doesn't work either, since when I retrieve the view I get
>> as many rows as the selected docs, with count 1. Perhaps my
>> description was confusing, since date is not something like YYMMDD,
>> but YYMMDDhhmmss. Therefore all the emitted keys are different and the
>> reduce function can't do any aggregation.
> This doesn't matter at all.

Why? I've got these functions, which are pretty similar to your ones:

function(doc) {
  if(doc.type == "item") {
    emit([doc.node,], null);

function(key, values, rereduce) {
  if(rereduce) {
    return sum(values);
  } else {
    return values.length;

The node is the bucket name, updated is when the item has been
inserted (converted to seconds from the epoc). Then I retrieve this
view (cut & paste from the browser), in which I want all the docs
newer then 1248650362


What I get is:


I really can't understand what I'm doing wrong...

> Total rows always reflects the number of rows in the view. It can
> cause some confusion, but the other way around I don't know that it'd
> cause any less.
> Also, are you checking the value of the assumed single return row? If
> you're not getting a single returned row then something is wrong. If
> you are and it's wrong, then its wrong or I'm wrong. Either way, I'm
> confused...

Indeed... I'm not getting a single returned row and I can't figure out
how it can happen since date changes for each row
(It is clear to me how count all the items in a bucket, but not how to
do it in a range of dates specified in the query paramentes...)


Fabio Forno, Ph.D.
Bluendo srl
jabber id:

View raw message