couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Joseph Davis <paul.joseph.da...@gmail.com>
Subject Re: Reduce Only
Date Thu, 07 Oct 2010 02:24:17 GMT
Also, you might want to try the _sum built-in reduce method. 



On Oct 6, 2010, at 10:10 PM, Nick Poulden <nick@domine.co.uk> wrote:

> Hi,
> 
> Is it possible to *only* store the reduce value of a view?
> 
> I'm storing a large database of orders for my online takeaway ordering
> website and collating stats, specifically the number of times a particular
> dish has been ordered. The view looks something like this:
> 
> // Map
> function(doc) {
>  if(doc.restaurant_id && doc.order_items) {
>    for(var i=0; i< doc.order_items.length; i++) {
>      emit([doc.restaurant_id, doc.order_items[i].title], 1)
>    }
>  }
> }
> 
> // Reduce
> function(keys, values, rereduce) {
>  return sum(values);
> }
> 
> The problem is that there are tons of documents in the view index that
> aren't much use and view indexing is taking about 10 times longer since I
> added this function. The only thing I want to store is the reduce value. Is
> that possible, or is it a feature that may be added at some point in the
> future?
> 
> Thanks,
> 
> Nick Poulden
> http://www.e-resistible.co.uk

Mime
View raw message