incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randall Leeds <randall.le...@gmail.com>
Subject Re: Question on selecting on reduce values
Date Sat, 01 May 2010 00:49:46 GMT
I believe you could accomplish what you want with a list function:

http://books.couchdb.org/relax/design-documents/lists

I've never used one myself, but my impression is that you could simply not
send() any data for rows that have less than some number for the value.

Of course, I don't know if you can do group reduce with a list function. Can
any devs chime in on whether couch still obeys query strings and allows a
group reduce to be sent to a list?

Ideally you could send in your variable threshold as an additional query
parameter, available to the list function in the request object.

Something to play with and if it can't be made to work now my gut says it
should be possible and there's a patch to be made.

Again, disclaimer: never used a list function and answering from my phone.

-Randall

Sent from my mind control space transport super-dome.

On Apr 30, 2010 4:44 PM, "Cesar Delgado" <beettlle@ymail.com> wrote:

I've had a map/reduce view that will tell me how many of a certain name
there are in the Database.  It's very simple:

Map:
function(doc) {
fileVer = doc._id + "?rev=" + doc._rev emit(doc.filename, 1);
}

Reduce:
function(key, values) { return sum(values) ;
}

Now what I want to do is be able to select by the count that is returned to
me.  Basicaly I want to be able to ask the database to show me all the
doc.filename where sum(values) > arbitrary_number.

I've tried hard-coding it:
function(key, values) {
if (sum(values) > 2) { return sum(values) ;
}
}

But that gives me an error.

I'd be perfectly happy hardoding the value if needed but would love to have
it be a variable.

What subtlety am I missing here?

Thanks all,

-Cesar

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message